On April 22, 2025 12:08:51 AM PDT, Sam James <s...@gentoo.org> wrote:
>Kees Cook <k...@kernel.org> writes:
>
>> On Thu, Apr 10, 2025 at 05:17:51PM -0700, Keith Packard wrote:
>>> A target using 16-bit ints won't have enough bits to hold the whole
>>> flag_sanitize set. Be explicit about using uint32 for the attribute data.
>>>
>>> Signed-off-by: Keith Packard <kei...@keithp.com>
>>> ---
>>> gcc/c-family/c-attribs.cc | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
>>> index 5a0e3d328ba..2a4ae10838a 100644
>>> --- a/gcc/c-family/c-attribs.cc
>>> +++ b/gcc/c-family/c-attribs.cc
>>> @@ -1420,12 +1420,12 @@ add_no_sanitize_value (tree node, unsigned int
>>> flags)
>>> if (flags == old_value)
>>> return;
>>>
>>> - TREE_VALUE (attr) = build_int_cst (unsigned_type_node, flags);
>>> + TREE_VALUE (attr) = build_int_cst (uint32_type_node, flags);
>>> }
>>> else
>>> DECL_ATTRIBUTES (node)
>>> = tree_cons (get_identifier ("no_sanitize"),
>>> - build_int_cst (unsigned_type_node, flags),
>>> + build_int_cst (uint32_type_node, flags),
>>> DECL_ATTRIBUTES (node));
>>> }
>>
>> This looks correct to me. Martin, is this something you (or someone
>> else) can get committed for GCC 15?
>
>Martin isn't involved with GCC development anymore. But it's not clear
Ah! Okay, it seemed like he had some relatively recent commits.
>to me why this is critical for GCC 15. (Any further patches for 15.1
>need to be both approved and then approved by release managers).
It's not critical. I was thinking it would be nice to have in 15 as it was a
small/easy change.
>Did you need this for something on the Linux side?
No, this is not needed for Linux. I have been following Keith's use of the
sanitizers on the picolibc project[1] and thought I might be able to help find
someone that could commit this fix.
>More likely that if approved, it could then go into 15.2 which will be
>in a few months (not a year unlike > X.3).
Any release is fine. My suggestion for 15 was just based on seeing it as a
trivial fix and not sufficiently understanding the GCC release process. :)
Thanks for looking at it!
-Kees
[1] https://keithp.com/blogs/sanitizer-fun/
--
Kees Cook