mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>
Subject: Re: [PATCH] static_call: Fix the module key fixup
Date: Thu, 25 Feb 2021 22:11:51 -0500	[thread overview]
Message-ID: <20210225221151.7f9f04d7@oasis.local.home> (raw)
In-Reply-To: <20210225220351.GE4746@worktop.programming.kicks-ass.net>

On Thu, 25 Feb 2021 23:03:51 +0100
Peter Zijlstra <peterz@infradead.org> wrote:

> Subject: static_call: Fix the module key fixup
> 
> Provided the target address of a R_X86_64_PC32 relocation is aligned,
> the low two bits should be invariant between the relative and absolute
> value.
> 
> Turns out the address is not aligned and things go sideways, ensure we
> transfer the bits in the absolute form when fixing up the key address.
> 

Link: https://lore.kernel.org/lkml/20210225131221.11dab26e@gandalf.local.home/

> Reported-by: Steven Rostedt <rostedt@goodmis.org>

Tested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
>  kernel/static_call.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/static_call.c b/kernel/static_call.c
> index 6906c6ec4c97..ae825295cf68 100644
> --- a/kernel/static_call.c
> +++ b/kernel/static_call.c
> @@ -349,7 +349,8 @@ static int static_call_add_module(struct module *mod)
>  	struct static_call_site *site;
>  
>  	for (site = start; site != stop; site++) {
> -		unsigned long addr = (unsigned long)static_call_key(site);
> +		unsigned long s_key = (long)site->key + (long)&site->key;
> +		unsigned long addr = s_key & ~STATIC_CALL_SITE_FLAGS;
>  		unsigned long key;
>  
>  		/*
> @@ -373,8 +374,8 @@ static int static_call_add_module(struct module *mod)
>  			return -EINVAL;
>  		}
>  
> -		site->key = (key - (long)&site->key) |
> -			    (site->key & STATIC_CALL_SITE_FLAGS);
> +		key |= s_key & STATIC_CALL_SITE_FLAGS;
> +		site->key = key - (long)&site->key;
>  	}
>  
>  	return __static_call_init(mod, start, stop);


  reply	other threads:[~2021-02-26  3:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25 18:12 WARNING on latest master due to DYNAMIC_PREEMPT and cond_resched() Steven Rostedt
2021-02-25 22:03 ` [PATCH] static_call: Fix the module key fixup Peter Zijlstra
2021-02-26  3:11   ` Steven Rostedt [this message]
2021-03-01 10:16   ` [tip: locking/urgent] " tip-bot2 for Peter Zijlstra
2021-03-06 11:54   ` [tip: locking/core] " tip-bot2 for Peter Zijlstra

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=20210225221151.7f9f04d7@oasis.local.home \
    --to=rostedt@goodmis.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®