[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250822100346.GI3419281@noisy.programming.kicks-ass.net>
Date: Fri, 22 Aug 2025 12:03:46 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Kees Cook <kees@...nel.org>
Cc: Qing Zhao <qing.zhao@...cle.com>, Richard Biener <rguenther@...e.de>,
Andrew Pinski <andrew.pinski@....qualcomm.com>,
"gcc-patches@....gnu.org" <gcc-patches@....gnu.org>,
Joseph Myers <josmyers@...hat.com>, 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>,
"linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>
Subject: Re: [RFC PATCH 3/7] kcfi: Add core Kernel Control Flow Integrity
infrastructure
On Thu, Aug 21, 2025 at 10:15:31PM -0700, Kees Cook wrote:
> On Thu, Aug 21, 2025 at 06:09:08PM +0000, Qing Zhao wrote:
> > > On Aug 21, 2025, at 10:25, Peter Zijlstra <peterz@...radead.org> wrote:
> > > kCFI changes every function to have a preamble like (with IBT and
> > > retpolines and all the modern crap on):
> >
> > Does “every function” mean all the function in the compilation? Not only the function whose address is taken?
>
> I tried to explain the specific logic on how the set of functions getting
> preambles is chosen in this other reply:
> https://lore.kernel.org/linux-hardening/202508211258.8DEE293@keescook/
>
> If that didn't answer your question, let me know and I'll try again. :)
One detail that might be interesting is that ENDBR and the __cfi_\func
preamble should be the same condition. The way these features are
exposed doesn't make this obvious.
And in fact, marking an address taken function with __noendbr will
result in a function that has a __cfi_\func preamble, but no ENDBR
(clang-20).
And while there is both a __noendbr and __nocfi attribute, they are
*VERY* different from one another. Where __noendbr inhibits the emission
of ENDBR and basically marks the function as impossible to reach with an
indirect call, the __nocfi attribute inhibits the CALL modification.
Notably, there is no function attribute to inhibit the __cfi_\func
preamble (and I'm arguing __noendbr should have that effect).
OTOH a function without __cfi_\func preamble but with ENDBR is 'unsafe',
but usable with a __nocfi call (typically reserved for calling external
code, like firmware). Anyway, we don't currently have means of
expressing this to the compiler (also, I don't care much in this case --
I think we should taint the kernel on EFI calls :-).
Powered by blists - more mailing lists