From: "hanwei (K)" <hanwei62@h-partners.com>
To: Andrew Pinski <andrew.pinski@oss.qualcomm.com>,
Kees Cook <kees@kernel.org>
Cc: Indu Bhagat <indu.bhagat@oracle.com>,
Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>,
Qing Zhao <qing.zhao@oracle.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
"linux-hardening@vger.kernel.org"
<linux-hardening@vger.kernel.org>
Subject: Re: [PATCH v4] Fix sanitizer attribute infrastructure to use standard TREE_LIST format [PR113264]
Date: Wed, 25 Feb 2026 06:27:14 +0000 [thread overview]
Message-ID: <062a7de7ed924307b13c74afe1ec95ee@h-partners.com> (raw)
On Wed, Feb 25, 2026 at 12:28 AM hstk30 <hanwei62@huawei.com> wrote:
> On Mon, Feb 9, 2026 at 12:28 AM Andrew Pinski <andrew.pinski@oss.qualcomm.com> wrote:
> >
> > On Thu, Sep 4, 2025 at 10:43 AM Kees Cook <kees@kernel.org> wrote:
> > >
> > > The __attribute__((__copy__)) functionality was crashing when
> > > copying sanitizer-related attributes because these attributes
> > > violated the standard GCC attribute infrastructure by storing
> > > INTEGER_CST values directly instead of wrapping them in TREE_LIST like all other attributes.
> > >
> > > Wrap sanitizer attributes INTEGER_CST values in TREE_LIST structures
> > > to follow the same pattern as other attributes. This eliminates the
> > > copy_list() crashes when copying sanitizer attributes:
> > >
> > > test.c:4:1: internal compiler error: tree check: expected tree that contains ‘common’ structure, have ‘integer_cst’ in copy_list, at tree.cc:1427
> > > 4 | __attribute__((__copy__(__tanh)));
> > > | ^~~~~~~~~~~~~
> > > 0x859d06 tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)
> > > ../../gcc/gcc/tree.cc:9126
> > > 0x860f78 contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*)
> > > ../../gcc/gcc/tree.h:3748
> > > 0x860f78 copy_list(tree_node*)
> > > ../../gcc/gcc/tree.cc:1427
> > > 0xa755a5 handle_copy_attribute
> > > ../../gcc/gcc/c-family/c-attribs.cc:3077
> >
> >
> > I am not a fan of the wrapping because it increases the memory usage
> > slightly but it is required since the rest of the attributes code
> > requires TREE_LIST here.
> >
> > So Ok. I will do final testing either Monday or Tuesday and push it after that.
>
> So this causes some ICEs in the testsuite:
> FAIL: c-c++-common/asan/inline-kernel.c -O0 (internal compiler
> error: in tree_to_sanitize_code_type, at tree.cc:6704)
>
> 0xa4376b fancy_abort(char const*, int, char const*)
> /home/apinski/src/upstream-gcc-new/gcc/gcc/diagnostics/context.cc:1812
> 0x92f581 tree_to_sanitize_code_type(tree_node const*)
> /home/apinski/src/upstream-gcc-new/gcc/gcc/tree.cc:6704
> 0x92f581 tree_to_sanitize_code_type(tree_node const*)
> /home/apinski/src/upstream-gcc-new/gcc/gcc/tree.cc:6702
> 0x128bea2 print_no_sanitize_attr_value
> /home/apinski/src/upstream-gcc-new/gcc/gcc/tree-cfg.cc:8223
> 0x128bea2 dump_function_to_file(tree_node*, _IO_FILE*, dump_flag)
> /home/apinski/src/upstream-gcc-new/gcc/gcc/tree-cfg.cc:8276
>
>
> Looks like you forgot to update dump_function_to_file too.
> Can you double check all of the locations that use tree_to_sanitize_code_type to make sure they all have been fixed?
Fix this fail by below patch:
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 66ea54f8b85..808b8000603 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -8220,7 +8220,10 @@ dump_default_def (FILE *file, tree def, int spc, dump_flags_t flags)
static void
print_no_sanitize_attr_value (FILE *file, tree value)
{
- sanitize_code_type flags = tree_to_sanitize_code_type (value);
+ /* Extract the INTEGER_CST from the TREE_LIST wrapper. */
+ gcc_assert (TREE_CODE (value) == TREE_LIST);
+ sanitize_code_type flags = tree_to_sanitize_code_type (TREE_VALUE (value));
+
bool first = true;
for (int i = 0; sanitizer_opts[i].name != NULL; ++i)
{
I have checked the patch which first introduces the tree_to_sanitize_code_type
(https://inbox.sourceware.org/gcc-patches/20250813104306.20804-3-claudiu.zissulescu-ianculescu@oracle.com/)
>
> Thanks,
> Andrew
>
> >
> > Thanks,
> > Andrew
next reply other threads:[~2026-02-25 6:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 6:27 hanwei (K) [this message]
[not found] <cb90ec7f5d724213b164e9f849675907@h-partners.com>
2026-03-07 19:38 ` [PATCH v4] Fix sanitizer attribute infrastructure to use standard TREE_LIST format [PR113264] Andrew Pinski
-- strict thread matches above, loose matches on Subject: below --
2025-09-04 17:43 Kees Cook
2026-02-06 8:05 ` Andrew Pinski
2026-02-06 18:16 ` Kees Cook
2026-02-09 8:28 ` Andrew Pinski
2026-02-10 2:34 ` Andrew Pinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=062a7de7ed924307b13c74afe1ec95ee@h-partners.com \
--to=hanwei62@h-partners.com \
--cc=andrew.pinski@oss.qualcomm.com \
--cc=claudiu.zissulescu-ianculescu@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=indu.bhagat@oracle.com \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=qing.zhao@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox