android_kernel_oneplus_msm8998/arch/x86/mm
Nadav Amit 122b3ad3a0 x86/mm: Use WRITE_ONCE() when setting PTEs
commit 9bc4f28af75a91aea0ae383f50b0a430c4509303 upstream.

When page-table entries are set, the compiler might optimize their
assignment by using multiple instructions to set the PTE. This might
turn into a security hazard if the user somehow manages to use the
interim PTE. L1TF does not make our lives easier, making even an interim
non-present PTE a security hazard.

Using WRITE_ONCE() to set PTEs and friends should prevent this potential
security hazard.

I skimmed the differences in the binary with and without this patch. The
differences are (obviously) greater when CONFIG_PARAVIRT=n as more
code optimizations are possible. For better and worse, the impact on the
binary with this patch is pretty small. Skimming the code did not cause
anything to jump out as a security hazard, but it seems that at least
move_soft_dirty_pte() caused set_pte_at() to use multiple writes.

Signed-off-by: Nadav Amit <namit@vmware.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/20180902181451.80520-1-namit@vmware.com
[bwh: Backported to 4.4:
 - Drop changes in pmdp_establish(), native_set_p4d(), pudp_set_access_flags()
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-16 19:45:09 +02:00
..
kmemcheck
amdtopology.c
dump_pagetables.c Fix user-visible spelling error 2015-12-15 10:15:57 -08:00
extable.c Revert "x86/mm: Expand the exception table logic to allow new handling options" 2016-10-31 19:56:26 -06:00
fault.c x86/mm: Remove in_nmi() warning from vmalloc_fault() 2018-09-19 22:48:58 +02:00
gup.c mm: replace get_user_pages_unlocked() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
highmem_32.c kmap_atomic_to_page() has no users, remove it 2015-11-09 15:11:24 -08:00
hugetlbpage.c mm: larger stack guard gap, between vmas 2017-06-26 07:13:11 +02:00
init.c x86/speculation/l1tf: Fix off-by-one error when warning that system has too much RAM 2018-09-05 09:18:38 +02:00
init_32.c x86/mm: Warn on W^X mappings 2015-10-06 11:11:48 +02:00
init_64.c kaiser: add "nokaiser" boot option, using ALTERNATIVE 2018-01-05 15:44:25 +01:00
iomap_32.c Merge branch 'x86-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-06-22 17:59:09 -07:00
ioremap.c x86/mm/kmmio: Fix mmiotrace for page unaligned addresses 2018-02-25 11:03:41 +01:00
kaiser.c x86/kaiser: fix build error with KASAN && !FUNCTION_GRAPH_TRACER 2018-02-16 20:09:40 +01:00
kasan_init_64.c x86/kasan: Write protect kasan zero shadow 2018-01-10 09:27:08 +01:00
kmmio.c x86/mm/kmmio: Make the tracer robust against L1TF 2018-08-15 17:42:11 +02:00
Makefile KPTI: Rename to PAGE_TABLE_ISOLATION 2018-01-05 15:44:26 +01:00
mm_internal.h
mmap.c x86/speculation/l1tf: Fix off-by-one error when warning that system has too much RAM 2018-09-05 09:18:38 +02:00
mmio-mod.c
mpx.c mm: replace get_user_pages() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
numa.c mem-hotplug: handle node hole when initializing numa_meminfo. 2015-09-08 15:35:28 -07:00
numa_32.c x86/mm/32: Set the '__vmalloc_start_set' flag in initmem_init() 2017-06-26 07:13:09 +02:00
numa_64.c
numa_emulation.c x86/numa_emulation: Fix emulated-to-physical node mapping 2018-10-10 08:52:03 +02:00
numa_internal.h
pageattr-test.c x86/mm/pat: Make mm/pageattr[-test].c explicitly non-modular 2015-08-25 09:48:38 +02:00
pageattr.c x86/mm/pat: Prevent hang during boot when mapping pages 2018-11-10 07:41:35 -08:00
pat.c x86/io: add interface to reserve io memtype for a resource range. (v1.1) 2018-09-09 20:04:36 +02:00
pat_internal.h x86/mm/pat: Convert to pr_*() usage 2015-05-27 14:40:59 +02:00
pat_rbtree.c x86/mm/pat: Convert to pr_*() usage 2015-05-27 14:40:59 +02:00
pf_in.c
pf_in.h
pgtable.c x86/mm: Use WRITE_ONCE() when setting PTEs 2019-05-16 19:45:09 +02:00
pgtable_32.c
physaddr.c
physaddr.h
setup_nx.c x86/cpufeature: Carve out X86_FEATURE_* 2018-07-17 11:31:44 +02:00
srat.c x86/mm/srat: Print non-volatile flag in SRAT 2015-09-02 09:33:25 +02:00
testmmiotrace.c
tlb.c x86/speculation: Use Indirect Branch Prediction Barrier in context switch 2018-07-25 10:18:21 +02:00