mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Ilie Halip <ilie.halip@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: objtool warning "uses BP as a scratch register" with clang-9
Date: Fri, 30 Aug 2019 10:14:22 -0500	[thread overview]
Message-ID: <20190830151422.o4pbvjyravrz2wre@treble> (raw)
In-Reply-To: <CAK8P3a0ddxbGVj974XS+PM_mSJDu=aGfTGarjmqMCuLKn81mRg@mail.gmail.com>

On Fri, Aug 30, 2019 at 12:44:24PM +0200, Arnd Bergmann wrote:
> On Fri, Aug 30, 2019 at 1:24 AM Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> > On Wed, Aug 28, 2019 at 05:40:01PM +0200, Arnd Bergmann wrote:
> > > diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
> > > index 8eb7193e158d..fd49d28abbc5 100644
> > > --- a/arch/x86/kernel/signal.c
> > > +++ b/arch/x86/kernel/signal.c
> > > @@ -414,6 +414,9 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
> > >                  */
> > >                 put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
> > >         } put_user_catch(err);
> > > +
> > > +       if (current->sas_ss_flags & SS_AUTODISARM)
> > > +               sas_ss_reset(current);
> > >
> > >         err |= copy_siginfo_to_user(&frame->info, &ksig->info);
> > >         err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
> 
> > > diff --git a/include/linux/signal.h b/include/linux/signal.h
> > > index 67ceb6d7c869..9056239787f7 100644
> > > --- a/include/linux/signal.h
> > > +++ b/include/linux/signal.h
> > > @@ -435,8 +435,6 @@ int __save_altstack(stack_t __user *, unsigned long);
> > >         put_user_ex((void __user *)t->sas_ss_sp, &__uss->ss_sp); \
> > >         put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \
> > >         put_user_ex(t->sas_ss_size, &__uss->ss_size); \
> > > -       if (t->sas_ss_flags & SS_AUTODISARM) \
> > > -               sas_ss_reset(t); \
> > >  } while (0);
> > >
> > >  #ifdef CONFIG_PROC_FS
> >
> > Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
> 
> Thanks! Before I submit this version for inclusion, let's make sure this
> is the best variant. I noticed later that save_altstack_ex() is meant to
> behave the same as __save_altstack(), but my patch breaks that
> assumption.

Good point.

There's also compat_save_altstack_ex() -- which presumably needs the
same fix? -- and __compat_save_altstack().

> Two other alternatives I can think of are
> 
> - completely open-code save_altstack_ex() in its only call site on x86,
>   in addition to the change above

But it has two call sites: the 32-bit and 64-bit versions of
save_altstack_ex().

> - explicitly mark memset() as an exception in objtool in
>   uaccess_safe_builtin[], assuming that is actually safe.

I wonder if this might open up more theoretical SMAP holes for other
callers to memset().

What about just adding a couple of WRITE_ONCE's to sas_ss_reset()?  That
would probably be the least disruptive option.

Or even better, it would be great if we could get Clang to change their
memset() insertion heuristics, so that KASAN acts more like non-KASAN
code in that regard.

-- 
Josh

  reply	other threads:[~2019-08-30 15:14 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 12:30 Arnd Bergmann
2019-08-27 14:51 ` Josh Poimboeuf
2019-08-27 14:59   ` Ilie Halip
2019-08-27 19:00     ` Arnd Bergmann
2019-08-27 19:22       ` Josh Poimboeuf
2019-08-27 19:47         ` Arnd Bergmann
2019-08-27 21:21           ` Nick Desaulniers
2019-08-28  9:00             ` Arnd Bergmann
2019-08-28 14:06               ` Arnd Bergmann
2019-08-28 14:51               ` Josh Poimboeuf
2019-08-28 15:29                 ` Arnd Bergmann
2019-08-28 17:57                   ` Josh Poimboeuf
2019-08-28 19:41                     ` Arnd Bergmann
2019-08-28 15:13               ` Arnd Bergmann
2019-08-28 15:22                 ` Josh Poimboeuf
2019-08-28 15:28                   ` Arnd Bergmann
2019-08-28 15:40                     ` Arnd Bergmann
2019-08-29 23:24                       ` Josh Poimboeuf
2019-08-30 10:44                         ` Arnd Bergmann
2019-08-30 15:14                           ` Josh Poimboeuf [this message]
2019-08-30 15:58                             ` Arnd Bergmann
2019-08-30 16:12                               ` David Laight
2019-08-30 16:03                             ` Linus Torvalds
2019-08-29 17:34                     ` Josh Poimboeuf
2019-08-29 18:30                       ` Linus Torvalds
2019-08-29 20:21                         ` Arnd Bergmann
2019-08-29 22:26                           ` Linus Torvalds
2019-08-30 15:02                             ` Josh Poimboeuf
2019-08-30 15:39                               ` David Laight
2019-08-30 15:48                               ` Linus Torvalds
2019-08-30 15:55                                 ` David Laight
2019-08-30 16:01                                   ` Linus Torvalds
2019-08-30 16:42                                     ` David Laight
2019-08-30 16:49                                 ` Josh Poimboeuf
2019-09-02  9:02                                   ` David Laight
2019-09-04 11:53                         ` Geert Uytterhoeven
2019-08-28 22:13         ` Nick Desaulniers
2019-08-29  0:28           ` Josh Poimboeuf

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=20190830151422.o4pbvjyravrz2wre@treble \
    --to=jpoimboe@redhat.com \
    --cc=arnd@arndb.de \
    --cc=clang-built-linux@googlegroups.com \
    --cc=ilie.halip@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.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®