Re: [GIT PULL] overflow updates for v5.15-rc1

From: Linus Torvalds
Date: Sat Sep 04 2021 - 16:56:18 EST


On Thu, Sep 2, 2021 at 8:22 PM Kees Cook <keescook@xxxxxxxxxxxx> wrote:
>
> Please pull these overflow updates for v5.15-rc1.

I pulled and then immediately unpulled again.

You can't add new warnings without fixing them, and this adds some
HORRENDOUSLY ugly new warnings that would most definitely hide other
warnings.

It doesn't matter one whit if the new warnings are from some
test-file, they are not acceptable for a build.

Make any tests separate from a real kernel build, because if "make
allmodconfig" results in hundreds of lines of warning crud, it's
useless garbage.

Linus

---

warning: unsafe memchr() usage lacked '__read_overflow' warning in
lib/test_fortify/read_overflow-memchr.c
lib/test_fortify/test_fortify.h: In function ‘do_fortify_tests’:
lib/test_fortify/read_overflow-memchr.c:3:9: error: statement with no
effect [-Werror=unused-value]
3 | memchr(small, 0x7A, sizeof(small) + 1)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/test_fortify/test_fortify.h:34:9: note: in expansion of macro ‘TEST’
34 | TEST;
| ^~~~
In file included from ./include/linux/string.h:253,
from ./include/linux/bitmap.h:10,
from ./include/linux/cpumask.h:12,
from ./arch/x86/include/asm/cpumask.h:5,
from ./arch/x86/include/asm/msr.h:11,
.. lots of noise ..

In function ‘strncpy’,
inlined from ‘do_fortify_tests’ at lib/test_fortify/test_fortify.h:34:2:
./include/linux/fortify-string.h:56:17: error: call to
‘__write_overflow’ declared with attribute error: detected write
beyond size of object (1st parameter)
56 | __write_overflow();
| ^~~~~~~~~~~~~~~~~~
warning: unsafe strncpy() usage lacked '__write_overflow' warning in
lib/test_fortify/write_overflow-strncpy.c
In file included from ./include/linux/string.h:253,
from ./include/linux/bitmap.h:10,
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 lib/test_fortify/test_fortify.h:4,
from lib/test_fortify/write_overflow-strncpy.c:5: