All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Andy Lutomirski <luto@kernel.org>
Cc: Gabriel Krisman Bertazi <krisman@collabora.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Christoph Hellwig <hch@lst.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Kees Cook <keescook@chromium.org>, X86 ML <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel@collabora.com
Subject: Re: [PATCH 2/6] arch: x86: Wrap TIF_IA32 checks
Date: Wed, 29 Jul 2020 08:59:55 +0200	[thread overview]
Message-ID: <20200729065955.GA32309@lst.de> (raw)
In-Reply-To: <CALCETrV_HJCrDLCKLrqNbLiOsoEcC9M7zn-v_hcVMvDgnWW8yw@mail.gmail.com>

On Tue, Jul 28, 2020 at 08:43:27PM -0700, Andy Lutomirski wrote:
> > index d4edf281fff4..d39f9b3ae683 100644
> > --- a/arch/x86/include/asm/compat.h
> > +++ b/arch/x86/include/asm/compat.h
> > @@ -181,7 +181,7 @@ static inline void __user *arch_compat_alloc_user_space(long len)
> >  {
> >         compat_uptr_t sp;
> >
> > -       if (test_thread_flag(TIF_IA32)) {
> > +       if (TASK_IA32(current)) {
> >                 sp = task_pt_regs(current)->sp;
> 
> Christoph, you spend a *lot* more time looking at this stuff lately
> than I do, but this looks totally wrong.  Shouldn't this be either:
> 
> sp = task_pt_regs(current)->sp;
> 
> /* This might be a compat syscall issued via int $0x80 from 64-bit-ABI code. */
> if (user_64bit_mode(task_pt_regs(current))
>   sp -= 128;
> 
> Or perhaps the same thing without the user_64bit_mode() check at all?
> There shouldn't be much if any harm done by respecting the redzone
> unnecessarily.

compat_alloc_user_space is only used when either called from compat
calls or if in_compat_syscall() is true (and there are very few callers
left, and we plan to kill it off entirely..).

Which means we are either called from an i386 or x32 syscall, but then
again IIRC user_64bit_mode would also return true for x32.  So your
above version looks correct, and I'd also be tempted to just always
respect the redzone.

> Surely this should be:
> 
> if (user_64bit_mode(task_pt_regs(regs))

s/regs/current/

Btw, I wonder if want a shorthand for

	user_64bit_mode(task_pt_regs(thread))

instead of always open coding it.

  parent reply	other threads:[~2020-07-29  7:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28 20:22 [PATCH 0/6] Reclaim x86 psABI TIF flags Gabriel Krisman Bertazi
2020-07-28 20:22 ` [PATCH 1/6] arch: x86: Don't use TIF flags for mm context Gabriel Krisman Bertazi
2020-07-29  9:03   ` peterz
2020-07-28 20:22 ` [PATCH 2/6] arch: x86: Wrap TIF_IA32 checks Gabriel Krisman Bertazi
2020-07-29  3:43   ` Andy Lutomirski
2020-07-29  4:46     ` Gabriel Krisman Bertazi
2020-07-29  5:09       ` Andy Lutomirski
2020-07-29 18:11         ` Gabriel Krisman Bertazi
2020-07-29  6:59     ` Christoph Hellwig [this message]
2020-07-29  9:11     ` peterz
2020-07-28 20:22 ` [PATCH 3/6] arch: x86: Wrap TIF_X32 checks Gabriel Krisman Bertazi
2020-07-29  4:54   ` Andy Lutomirski
2020-07-28 20:22 ` [PATCH 4/6] arch: x86: Expose psABI on thread_info Gabriel Krisman Bertazi
2020-07-29  3:44   ` Andy Lutomirski
2020-07-28 20:22 ` [PATCH 5/6] arch: x86: Reclaim TIF_IA32 flag Gabriel Krisman Bertazi
2020-07-28 20:22 ` [PATCH 6/6] arch: x86: Reclaim TIF_X32 flag Gabriel Krisman Bertazi

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=20200729065955.GA32309@lst.de \
    --to=hch@lst.de \
    --cc=keescook@chromium.org \
    --cc=kernel@collabora.com \
    --cc=krisman@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.