From: Peter Zijlstra <peterz@infradead.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Josh Poimboeuf <jpoimboe@redhat.com>,
Jason Baron <jbaron@akamai.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mark Rutland <mark.rutland@arm.com>,
Kees Cook <keescook@chromium.org>
Subject: Re: [RFC PATCH 2/7] static_call: deal with unexported keys without cluttering up the API
Date: Tue, 9 Nov 2021 19:49:03 +0100 [thread overview]
Message-ID: <YYrCn3mc+EbY+OB/@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20211109164549.1724710-3-ardb@kernel.org>
On Tue, Nov 09, 2021 at 05:45:44PM +0100, Ard Biesheuvel wrote:
> diff --git a/include/linux/static_call_types.h b/include/linux/static_call_types.h
> index 5a00b8b2cf9f..0bb36294cce7 100644
> --- a/include/linux/static_call_types.h
> +++ b/include/linux/static_call_types.h
> @@ -32,15 +32,20 @@
> struct static_call_site {
> s32 addr;
> s32 key;
> + s32 tramp;
> };
I can't say I'm thrilled at growing this thing, but the cleanup is nice.
Perhaps we can increase alignment on struct static_call_key and instead
frob it in .key still?
>
> #define DECLARE_STATIC_CALL(name, func) \
> - extern struct static_call_key STATIC_CALL_KEY(name); \
> + extern __weak struct static_call_key STATIC_CALL_KEY(name); \
> extern typeof(func) STATIC_CALL_TRAMP(name);
I'm a little bit confused on how this actually works. What does a __weak
extern data symbol do?
A __weak function definition would create a module local instance of the
function barring a strong override.
But what does a __weak extern do?
> diff --git a/kernel/static_call.c b/kernel/static_call.c
> index 43ba0b1e0edb..360cc3cd0fbf 100644
> --- a/kernel/static_call.c
> +++ b/kernel/static_call.c
> @@ -366,18 +366,18 @@ static int static_call_add_module(struct module *mod)
> * means modules are allowed to call static_call_update() on
> * it.
> *
> - * Otherwise, the key isn't exported, and 'addr' points to the
> + * Otherwise, the key isn't exported, and 'tramp' points to the
> * trampoline so we need to lookup the key.
> *
> * We go through this dance to prevent crazy modules from
> * abusing sensitive static calls.
> */
> - if (!kernel_text_address(addr))
> + if (addr)
> continue;
This seems to imply that the __weak extern symbol gets resolved to 0 at
module link time.
>
> - key = tramp_key_lookup(addr);
> + key = tramp_key_lookup((unsigned long)offset_to_ptr(&site->tramp));
> if (!key) {
> - pr_warn("Failed to fixup __raw_static_call() usage at: %ps\n",
> + pr_warn("Failed to fixup static_call() usage at: %ps\n",
> static_call_addr(site));
> return -EINVAL;
> }
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-11-09 18:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 16:45 [RFC PATCH 0/7] static call updates Ard Biesheuvel
2021-11-09 16:45 ` [RFC PATCH 1/7] static_call: get rid of static_call_cond() Ard Biesheuvel
2021-11-09 18:38 ` Peter Zijlstra
2021-11-09 18:41 ` Ard Biesheuvel
2021-11-09 19:22 ` Peter Zijlstra
2021-11-09 19:32 ` Peter Zijlstra
2021-11-09 16:45 ` [RFC PATCH 2/7] static_call: deal with unexported keys without cluttering up the API Ard Biesheuvel
2021-11-09 18:49 ` Peter Zijlstra [this message]
2021-11-09 18:53 ` Ard Biesheuvel
2021-11-09 19:41 ` Peter Zijlstra
2021-11-09 16:45 ` [RFC PATCH 3/7] static_call: use helper to access non-exported key Ard Biesheuvel
2021-11-09 18:53 ` Peter Zijlstra
2021-11-09 18:54 ` Ard Biesheuvel
2021-11-09 19:42 ` Peter Zijlstra
2021-11-09 19:45 ` Ard Biesheuvel
2021-11-09 16:45 ` [RFC PATCH 4/7] static_call: fix broken static_call_query() for non-exported keys Ard Biesheuvel
2021-11-09 18:56 ` Peter Zijlstra
2021-11-09 16:45 ` [RFC PATCH 5/7] static_call: use non-function types to refer to the trampolines Ard Biesheuvel
2021-11-09 16:45 ` [RFC PATCH 6/7] static_call: rename EXPORT_ macros to be more self-explanatory Ard Biesheuvel
2021-11-09 19:00 ` Peter Zijlstra
2021-11-09 19:03 ` Ard Biesheuvel
2021-11-09 16:45 ` [RFC PATCH 7/7] static_call: add generic support for non-exported keys Ard Biesheuvel
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=YYrCn3mc+EbY+OB/@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=ardb@kernel.org \
--cc=jbaron@akamai.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rostedt@goodmis.org \
/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