[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALvbMcBYSzi=fb0XmGrgh_aP=rR9H+f-7PbX7cnvTm_T+vZynw@mail.gmail.com>
Date: Fri, 12 Dec 2025 17:29:43 -0800
From: Andrew Pinski <andrew.pinski@....qualcomm.com>
To: Kees Cook <kees@...nel.org>
Cc: Qing Zhao <qing.zhao@...cle.com>, Uros Bizjak <ubizjak@...il.com>,
Joseph Myers <josmyers@...hat.com>, Richard Biener <rguenther@...e.de>,
Jeff Law <jeffreyalaw@...il.com>, Andrew Pinski <pinskia@...il.com>,
Jakub Jelinek <jakub@...hat.com>, Martin Uecker <uecker@...raz.at>,
Peter Zijlstra <peterz@...radead.org>,
Ard Biesheuvel <ardb@...nel.org>, Jan Hubicka <hubicka@....cz>,
Richard Earnshaw <richard.earnshaw@....com>,
Richard Sandiford <richard.sandiford@....com>,
Marcus Shawcroft <marcus.shawcroft@....com>,
Kyrylo Tkachov <kyrylo.tkachov@....com>,
Kito Cheng <kito.cheng@...il.com>, Palmer Dabbelt <palmer@...belt.com>,
Andrew Waterman <andrew@...ive.com>,
Jim Wilson <jim.wilson.gcc@...il.com>,
Dan Li <ashimida.1990@...il.com>,
Sami Tolvanen <samitolvanen@...gle.com>,
Ramon de C Valle <rcvalle@...gle.com>,
Joao Moreira <joao@...rdrivepizza.com>,
Nathan Chancellor <nathan@...nel.org>,
Bill Wendling <morbo@...gle.com>,
"Osterlund, Sebastian" <sebastian.osterlund@...el.com>,
"Constable, Scott D" <scott.d.constable@...el.com>,
gcc-patches@....gnu.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH v9 1/7] typeinfo: Introduce KCFI typeinfo mangling API
On Fri, Dec 12, 2025 at 5:24 PM Kees Cook <kees@...nel.org> wrote:
>
> On Fri, Dec 12, 2025 at 03:07:51PM -0800, Andrew Pinski wrote:
> > On Tue, Dec 9, 2025 at 6:27 PM Kees Cook <kees@...nel.org> wrote:
> > [...]
> > > +uint32_t
> > > +typeinfo_get_hash (tree type)
> > > +{
> > > + gcc_assert (type != NULL_TREE);
> > > + uint32_t hash_state = 2166136261U; /* FNV-1a 32-bit offset basis. */
> > > +
> > > + mangle_type (type, nullptr, &hash_state);
> > > + return hash_state;
> > > +}
> >
> > It might make sense to do a few self_test here instead of (in addition
> > to) having a testcase.
> > This way the testing is done earlier.
>
> I tried to do this back in v2 and could not make it work. See [1] for
> more details on what I found, but basically I don't have access to the
> parser itself in the selftests, so I couldn't build end-to-end testing
> of arbitrary C (testing node types isn't really a sufficient test in my
> view). I could to basic type tests, but it would be redundant to what
> I ended up with in dg, and I didn't want to split up the testing.
I am asking for self-tests of the API and not depending on the C
parser. So generating some FUNCTION_TYPE types and then getting back
the hash and/or name.
> (testing node types isn't really a sufficient test in my view)
It might not be a fully sufficient test in itself; it does not mean it
is NOT a useful test to have. This is why I mentioned in addition to.
Testing the API outside of the end-to-end testing is a good thing and
can find bugs early on. GCC does not have enough self-tests really
and folks don't use it as much as we should.
Thanks,
Andrew Pinski
>
> If I'm missing some other way to do this, I'd be happy to give it a shot!
>
> -Kees
>
> [1] https://lore.kernel.org/linux-hardening/20250905002418.464643-1-kees@kernel.org/
>
> --
> Kees Cook
Powered by blists - more mailing lists