1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-24 17:23:25 -05:00
linux/arch/x86/mm
Kees Cook 184d47f0fd x86/mm: Avoid VLA in pgd_alloc()
Arnd Bergmann reported that turning on -Wvla found a new (unintended) VLA usage:

  arch/x86/mm/pgtable.c: In function 'pgd_alloc':
  include/linux/build_bug.h:29:45: error: ISO C90 forbids variable length array 'u_pmds' [-Werror=vla]
  arch/x86/mm/pgtable.c:190:34: note: in expansion of macro 'static_cpu_has'
   #define PREALLOCATED_USER_PMDS  (static_cpu_has(X86_FEATURE_PTI) ? \
                                    ^~~~~~~~~~~~~~
  arch/x86/mm/pgtable.c:431:16: note: in expansion of macro 'PREALLOCATED_USER_PMDS'
    pmd_t *u_pmds[PREALLOCATED_USER_PMDS];
                ^~~~~~~~~~~~~~~~~~~~~~

Use the actual size of the array that is used for X86_FEATURE_PTI,
which is known at build time, instead of the variable size.

[ mingo: Squashed original fix with followup fix to avoid bisection breakage, wrote new changelog. ]

Reported-by: Arnd Bergmann <arnd@arndb.de>
Original-written-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Toshi Kani <toshi.kani@hpe.com>
Fixes: 1be3f247c288 ("x86/mm: Avoid VLA in pgd_alloc()")
Link: http://lkml.kernel.org/r/20181008235434.GA35035@beast
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-10-09 08:55:07 +02:00
..
amdtopology.c
cpu_entry_area.c
debug_pagetables.c
dump_pagetables.c
extable.c
fault.c x86/dumpstack: Don't dump kernel memory based on usermode RIP 2018-08-31 17:08:22 +02:00
highmem_32.c
hugetlbpage.c
ident_map.c
init.c x86/mm: Add .bss..decrypted section to hold shared variables 2018-09-15 20:48:45 +02:00
init_32.c
init_64.c
iomap_32.c
ioremap.c
kasan_init_64.c
kaslr.c
kmmio.c
Makefile
mem_encrypt.c x86/mm: Add .bss..decrypted section to hold shared variables 2018-09-15 20:48:45 +02:00
mem_encrypt_boot.S
mem_encrypt_identity.c
mm_internal.h
mmap.c x86/speculation/l1tf: Fix off-by-one error when warning that system has too much RAM 2018-08-24 09:51:14 +02:00
mmio-mod.c
mpx.c
numa.c
numa_32.c
numa_64.c
numa_emulation.c
numa_internal.h
pageattr-test.c
pageattr.c x86/mce: Fix set_mce_nospec() to avoid #GP fault 2018-09-01 14:59:19 +02:00
pat.c x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses 2018-08-20 09:22:45 -07:00
pat_internal.h
pat_rbtree.c
pf_in.c
pf_in.h
pgtable.c x86/mm: Avoid VLA in pgd_alloc() 2018-10-09 08:55:07 +02:00
pgtable_32.c
physaddr.c
physaddr.h
pkeys.c
pti.c x86/pti: Fix section mismatch warning/error 2018-09-02 11:24:41 +02:00
setup_nx.c
srat.c
testmmiotrace.c
tlb.c x86/nmi: Fix NMI uaccess race against CR3 switching 2018-08-31 17:08:22 +02:00