alistair23-linux/arch/powerpc/lib
Daniel Axtens c69a48cdb3 powerpc: make feature-fixup tests fortify-safe
Testing the fortified string functions[1] would cause a kernel panic on
boot in test_feature_fixups() due to a buffer overflow in memcmp.

This boils down to things like this:

  extern unsigned int ftr_fixup_test1;
  extern unsigned int ftr_fixup_test1_orig;

  check(memcmp(&ftr_fixup_test1, &ftr_fixup_test1_orig, size) == 0);

We know that these are asm labels so it is safe to read up to 'size'
bytes at those addresses.

However, because we have passed the address of a single unsigned int to
memcmp, the compiler believes the underlying object is in fact a single
unsigned int.  So if size > sizeof(unsigned int), there will be a panic
at runtime.

We can fix this by changing the types: instead of calling the asm labels
unsigned ints, call them unsigned int[]s.  Therefore the size isn't
incorrectly determined at compile time and we get a regular unsafe
memcmp and no panic.

[1] http://openwall.com/lists/kernel-hardening/2017/05/09/2

Link: http://lkml.kernel.org/r/1497903987-21002-7-git-send-email-keescook@chromium.org
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Kees Cook <keescook@chromium.org>
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Tested-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-12 16:26:03 -07:00
..
alloc.c treewide: replace obsolete _refok by __ref 2016-08-02 17:31:41 -04:00
checksum_32.S powerpc: EX_TABLE macro for exception tables 2016-11-14 11:11:51 +11:00
checksum_64.S powerpc/64: Use optimized checksum routines on little-endian 2017-01-25 13:34:18 +11:00
checksum_wrappers.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
code-patching.c powerpc/lib/code-patching: Use alternate map for patch_instruction() 2017-07-03 23:12:19 +10:00
copy_32.S powerpc: get rid of zeroing, switch to RAW_COPY_USER 2017-04-06 15:08:42 -04:00
copypage_64.S powerpc/64: Fix naming of cache block vs. cache line 2017-02-06 19:46:04 +11:00
copypage_power7.S powerpc: Change vrX register defines to vX to match gcc and glibc 2015-03-16 18:32:11 +11:00
copyuser_64.S powerpc: get rid of zeroing, switch to RAW_COPY_USER 2017-04-06 15:08:42 -04:00
copyuser_power7.S powerpc: Tweak copy selection parameter in __copy_tofrom_user_power7() 2017-05-30 14:59:51 +10:00
crtsavres.S powerpc/64: Do not create new section for save/restore functions 2017-05-30 14:59:51 +10:00
div64.S powerpc: Fix a corner case in __div64_32 2005-10-20 09:37:02 +10:00
feature-fixups-test.S powerpc: Ensure the else case of feature sections will fit 2011-01-21 14:08:33 +11:00
feature-fixups.c powerpc: make feature-fixup tests fortify-safe 2017-07-12 16:26:03 -07:00
hweight_64.S ppc: move exports to definitions 2016-08-07 23:50:09 -04:00
ldstfp.S powerpc: EX_TABLE macro for exception tables 2016-11-14 11:11:51 +11:00
locks.c powerpc/spinlock: Fix spin_unlock_wait() 2016-06-14 16:05:44 +10:00
Makefile powerpc/lib/xor_vmx: Ensure no altivec code executes before enable_kernel_altivec() 2017-06-02 20:17:52 +10:00
mem_64.S Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2016-10-14 14:26:58 -07:00
memcmp_64.S ppc: move exports to definitions 2016-08-07 23:50:09 -04:00
memcpy_64.S ppc: move exports to definitions 2016-08-07 23:50:09 -04:00
memcpy_power7.S powerpc: Change vrX register defines to vX to match gcc and glibc 2015-03-16 18:32:11 +11:00
rheap.c powerpc: Various typo fixes 2016-06-14 13:58:26 +10:00
sstep.c powerpc/kprobes: Convert __kprobes to NOKPROBE_SYMBOL() 2017-04-23 20:32:25 +10:00
string.S powerpc: EX_TABLE macro for exception tables 2016-11-14 11:11:51 +11:00
string_64.S powerpc/64: Fix naming of cache block vs. cache line 2017-02-06 19:46:04 +11:00
test_emulate_step.c powerpc: emulate_step() tests for load/store instructions 2017-03-03 11:24:50 +11:00
vmx-helper.c powerpc: Introduce asm-prototypes.h 2016-06-16 22:39:54 +10:00
xor_vmx.c powerpc/lib/xor_vmx: Ensure no altivec code executes before enable_kernel_altivec() 2017-06-02 20:17:52 +10:00
xor_vmx.h powerpc/lib/xor_vmx: Ensure no altivec code executes before enable_kernel_altivec() 2017-06-02 20:17:52 +10:00
xor_vmx_glue.c powerpc/lib/xor_vmx: Ensure no altivec code executes before enable_kernel_altivec() 2017-06-02 20:17:52 +10:00