]> www.infradead.org Git - users/jedix/linux-maple.git/commit
compiler.h: Introduce __must_be_noncstr()
authorKees Cook <kees@kernel.org>
Thu, 6 Feb 2025 22:54:11 +0000 (14:54 -0800)
committerKees Cook <kees@kernel.org>
Mon, 3 Mar 2025 17:35:44 +0000 (09:35 -0800)
commit9f25b1fb1c93942af870428fa394b42fcda7572f
tree00ff8b533782929b7648d69cbb8c4232a92ed465
parent4c2d8a6a54ed8f6f32fc9cbddfaa72db1231ed1c
compiler.h: Introduce __must_be_noncstr()

In preparation for adding more type checking to the memtostr/strtomem*()
helpers, introduce the ability to check for the "nonstring" attribute.
This is the reverse of what was added to strscpy*() in commit 559048d156ff
("string: Check for "nonstring" attribute on strscpy() arguments").

Note that __annotated() must be explicitly tested for, as GCC added
__builtin_has_attribute() after it added the "nonstring" attribute. Do
so here to avoid the !__annotated() test triggering build failures
when __builtin_has_attribute() was missing but __nonstring was defined.
(I've opted to squash this fix into this patch so we don't end up with
a possible bisection target that would leave the kernel unbuildable.)

Reported-by: Venkat Rao Bagalkote <venkat88@linux.vnet.ibm.com>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reported-by: Michael Kelley <mhklinux@outlook.com>
Closes: https://lore.kernel.org/all/adbe8dd1-a725-4811-ae7e-76fe770cf096@linux.vnet.ibm.com/
Tested-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Kees Cook <kees@kernel.org>
include/linux/compiler.h
include/linux/compiler_types.h