Re: [PATCH v2 6/7] percpu: Add __alloc_size attributes for better bounds checking
From: Kees Cook <hidden>
Date: 2021-08-20 05:27:31
Also in:
linux-hardening, linux-mm, lkml
On Thu, Aug 19, 2021 at 10:11:15PM -0700, Andrew Morton wrote:
On Wed, 18 Aug 2021 14:40:20 -0700 Kees Cook [off-list ref] wrote:quoted
As already done in GrapheneOS, add the __alloc_size attribute for appropriate percpu allocator interfaces, to provide additional hinting for better bounds checking, assisting CONFIG_FORTIFY_SOURCE and other compiler optimizations.Caught one, I assume: In file included from ./include/linux/string.h:262, from ./include/linux/bitmap.h:11, from ./include/linux/cpumask.h:12, from ./arch/x86/include/asm/cpumask.h:5, from ./arch/x86/include/asm/msr.h:11, from ./arch/x86/include/asm/processor.h:22, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:60, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:55, from ./include/linux/mmzone.h:8, from ./include/linux/gfp.h:6, from ./include/linux/slab.h:15, from drivers/misc/lkdtm/heap.c:7: In function 'memset', inlined from 'lkdtm_VMALLOC_LINEAR_OVERFLOW' at drivers/misc/lkdtm/heap.c:27:2: ./include/linux/fortify-string.h:172:3: error: call to '__write_overflow' declared with attribute error: detected write beyond size of object passed as 1st parameter 172 | __write_overflow(); | ^~~~~~~~~~~~~~~~~~ make[3]: *** [drivers/misc/lkdtm/heap.o] Error 1 make[2]: *** [drivers/misc/lkdtm] Error 2 make[1]: *** [drivers/misc] Error 2 make: *** [drivers] Error 2 I want to get a kernel release out, so I'll hide mm-vmalloc-add-__alloc_size-attributes-for-better-bounds-checking.patch for now.
In the cover letter[1], I listed the needed fixes that were sent separately from this series. Quoting here:
To build without warnings, this series needs a couple small fixes for allmodconfig, which I sent separately: https://lore.kernel.org/lkml/20210818174855.2307828-5-keescook@chromium.org/ (local) https://lore.kernel.org/lkml/20210818044252.1533634-1-keescook@chromium.org/ (local) https://lore.kernel.org/lkml/20210818043912.1466447-1-keescook@chromium.org/ (local)
What you hit is the first one, which is already in Greg's tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/commit/?h=char-misc-next&id=e6d468d32cd084edd030a8bae76440b17b854b5c The other two have also been taken: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?h=staging-next&id=cbe34165cc1b7d1110b268ba8b9f30843c941639 https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/?id=a31e5a4158d03595ca4258b94397d4097be0ebe4 -Kees [1] https://lore.kernel.org/lkml/20210818214021.2476230-1-keescook@chromium.org/ (local) -- Kees Cook