Commit 9f25b1fb authored by Kees Cook's avatar Kees Cook
Browse files

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 559048d1
("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: default avatarVenkat Rao Bagalkote <venkat88@linux.vnet.ibm.com>
Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Reported-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Reported-by: default avatarMichael Kelley <mhklinux@outlook.com>
Closes: https://lore.kernel.org/all/adbe8dd1-a725-4811-ae7e-76fe770cf096@linux.vnet.ibm.com/


Tested-by: default avatarMichael Kelley <mhklinux@outlook.com>
Signed-off-by: default avatarKees Cook <kees@kernel.org>
parent 4c2d8a6a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment