linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Christoph Hellwig <hch@lst.de>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux- <kernel@vger.kernel.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/9] ARM: traps: use get_kernel_nofault instead of set_fs()
Date: Fri, 18 Sep 2020 08:42:03 +0100	[thread overview]
Message-ID: <20200918074203.GU1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <CAK8P3a22EiD-uMZQaBpHQYyy=MJ_7J-ih=6CtgH_9RXT6OOYvg@mail.gmail.com>

On Thu, Sep 17, 2020 at 07:29:37PM +0200, Arnd Bergmann wrote:
> On Tue, Sep 8, 2020 at 8:15 AM Christoph Hellwig <hch@lst.de> wrote:
> >
> > > +static void dump_mem(const char *, const char *, unsigned long, unsigned long, bool kernel_mode);
> >
> > This adds a pointlessly long line.
> 
> Fixed.
> 
> > And looking at the code I don't see why the argument is even needed.
> >
> > dump_mem() currently does an unconditional set_fs(KERNEL_DS), so it
> > should always use get_kernel_nofault.
> 
> I had looked at
> 
>         if (!user_mode(regs) || in_interrupt()) {
>                 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
>                          THREAD_SIZE + (unsigned
> long)task_stack_page(tsk), kernel_mode);
> 
> which told me that there should be at least some code path ending up in
> __die() that has in_interrupt() set but comes from user mode.
> 
> In this case, the memory to print would be a user pointer and cannot be
> accessed by get_kernel_nofault() (but could be accessed with
> "set_fs(KERNEL_DS); __get_user()").
> 
> I looked through the history now and the only code path I could
> find that would arrive here this way is from bad_mode(), indicating
> that there is probably a hardware bug or the contents of *regs are
> corrupted.

Yes, that's correct.  It isn't something entirely theoretical, although
we never see it now, it used to happen in the distant past due to saved
regs corruption.  If bad_mode() ever gets called, all bets are off and
we're irrecoverably crashing.

Note that in that case, while user_mode(regs) may return true or false,
regs->ARM_sp and regs->ARM_lr are always the SVC mode stack and return
address after regs has been stacked, and not the expected values for
the parent context (which we have most likely long since destroyed.)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2020-09-18  7:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-07 15:36 [PATCH 0/9] ARM: remove set_fs callers and implementation Arnd Bergmann
2020-09-07 15:36 ` [PATCH 1/9] mm/maccess: fix unaligned copy_{from,to}_kernel_nofault Arnd Bergmann
2020-09-08  6:11   ` Christoph Hellwig
2020-09-27  9:25   ` Linus Walleij
2020-09-07 15:36 ` [PATCH 2/9] ARM: traps: use get_kernel_nofault instead of set_fs() Arnd Bergmann
2020-09-08  6:15   ` Christoph Hellwig
2020-09-17 17:29     ` Arnd Bergmann
2020-09-18  7:42       ` Russell King - ARM Linux admin [this message]
2020-09-18 12:36         ` Arnd Bergmann
2020-09-07 15:36 ` [PATCH 3/9] ARM: oabi-compat: add epoll_pwait handler Arnd Bergmann
2020-09-08  6:16   ` Christoph Hellwig
2020-09-07 15:36 ` [PATCH 4/9] ARM: syscall: always store thread_info->syscall Arnd Bergmann
2020-09-28  9:41   ` Linus Walleij
2020-09-28 12:42     ` Arnd Bergmann
2020-09-28 15:08       ` Russell King - ARM Linux admin
2020-09-07 15:36 ` [PATCH 5/9] ARM: oabi-compat: rework epoll_wait/epoll_pwait emulation Arnd Bergmann
2020-09-08  6:20   ` Christoph Hellwig
2020-09-08 20:56     ` Arnd Bergmann
2020-09-07 15:36 ` [PATCH 6/9] ARM: oabi-compat: rework sys_semtimedop emulation Arnd Bergmann
2020-09-07 15:36 ` [PATCH 7/9] ARM: oabi-compat: rework fcntl64() emulation Arnd Bergmann
2020-09-07 15:36 ` [PATCH 8/9] ARM: uaccess: add __{get,put}_kernel_nofault Arnd Bergmann
2020-09-07 15:36 ` [PATCH 9/9] ARM: uaccess: remove set_fs() implementation Arnd Bergmann
2020-10-30 15:45 [PATCH v4 0/9] ARM: remove set_fs callers and implementation Arnd Bergmann
2020-10-30 15:49 ` [PATCH 1/9] mm/maccess: fix unaligned copy_{from,to}_kernel_nofault Arnd Bergmann
2020-10-30 15:49   ` [PATCH 2/9] ARM: traps: use get_kernel_nofault instead of set_fs() Arnd Bergmann
2020-11-06  9:02     ` Linus Walleij

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=20200918074203.GU1551@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=0x7f454c46@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=hch@lst.de \
    --cc=kernel@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).