Re: [PATCH v5 00/15] x86: Add support for Clang CFI
From: Kees Cook
Date: Thu Oct 28 2021 - 13:12:36 EST
On Thu, Oct 28, 2021 at 01:09:39PM +0200, Peter Zijlstra wrote:
> On Wed, Oct 27, 2021 at 03:27:59PM -0700, Kees Cook wrote:
>
> > Right -- though wouldn't just adding __ro_after_init do the same?
> >
> > DEFINE_STATIC_CALL(static_call_name, func_a) __ro_after_init;
>
> That breaks modules (and your jump_label patch doing the same is
> similarly broken).
Well that's no fun. :) I'd like to understand this better so I can fix
it!
>
> When a module is loaded that uses the static_call(), it needs to
> register it's .static_call_sites range with the static_call_key which
> requires modifying it.
Reading static_call_add_module() leaves me with even more questions. ;)
It looks like module static calls need to write to kernel text? I don't
understand. Is this when a module is using an non-module key for a call
site? And in that case, this happens:
key |= s_key & STATIC_CALL_SITE_FLAGS;
Where "key" is not in the module?
And the flags can be:
#define STATIC_CALL_SITE_TAIL 1UL /* tail call */
#define STATIC_CALL_SITE_INIT 2UL /* init section */
But aren't these per-site attributes? Why are they stored per-key?
if (!init && static_call_is_init(site))
continue;
...
arch_static_call_transform(site_addr, NULL, func,
static_call_is_tail(site));
--
Kees Cook