All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Dmitry Vyukov <dvyukov@google.com>,
	syzbot <syzbot+f09a12b2c77bfbbf51bd@syzkaller.appspotmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Alexandre Chartre <alexandre.chartre@oracle.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [syzbot] upstream boot error: WARNING in __context_tracking_enter
Date: Mon, 22 Mar 2021 17:22:41 +0000	[thread overview]
Message-ID: <20210322172241.GB80352@C02TD0UTHF1T.local> (raw)
In-Reply-To: <20210319101043.GU1463@shell.armlinux.org.uk>

Hi Russell,

On Fri, Mar 19, 2021 at 10:10:43AM +0000, Russell King - ARM Linux admin wrote:
> On Fri, Mar 19, 2021 at 10:54:48AM +0100, Dmitry Vyukov wrote:
> > .On Fri, Mar 19, 2021 at 10:44 AM syzbot
> > <syzbot+f09a12b2c77bfbbf51bd@syzkaller.appspotmail.com> wrote:
> > > syzbot found the following issue on:
> > >
> > > HEAD commit:    8b12a62a Merge tag 'drm-fixes-2021-03-19' of git://anongit..
> > > git tree:       upstream
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=17e815aed00000
> > > kernel config:  https://syzkaller.appspot.com/x/.config?x=cfeed364fc353c32
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=f09a12b2c77bfbbf51bd
> > > userspace arch: arm
> > >
> > > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > > Reported-by: syzbot+f09a12b2c77bfbbf51bd@syzkaller.appspotmail.com
> > 
> > 
> > +Mark, arm
> > It did not get far with CONFIG_CONTEXT_TRACKING_FORCE (kernel doesn't boot).
> 
> It seems that the path:
> 
> context_tracking_user_enter()
> user_enter()
> context_tracking_enter()
> __context_tracking_enter()
> vtime_user_enter()
> 
> expects preemption to be disabled. It effectively is, because local
> interrupts are disabled by context_tracking_enter().
> 
> However, the requirement for preemption to be disabled is not
> documented... so shrug. Maybe someone can say what the real requirements
> are here.

From dealing with this recently on arm64, theis is a bit messy. To
handle this robustly we need to do a few things in sequence, including
using the *_irqoff() variants of the context_tracking_user_*()
functions.

I wrote down the constraints in commit:
  
  23529049c6842382 ("arm64: entry: fix non-NMI user<->kernel transitions")

For user->kernel transitions, the arch code needs the following sequence
before invoking arbitrary kernel C code:

	lockdep_hardirqs_off(CALLER_ADDR0);
	user_exit_irqoff();
	trace_hardirqs_off_finish();

For kernel->user transitions, the arch code needs the following sequence
once it will no longer invoke arbitrary kernel C code, just before
returning to userspace:

	trace_hardirqs_on_prepare();
	lockdep_hardirqs_on_prepare(CALLER_ADDR0);
	user_enter_irqoff();
	lockdep_hardirqs_on(CALLER_ADDR0);

Thanks,
Mark.

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Dmitry Vyukov <dvyukov@google.com>,
	syzbot <syzbot+f09a12b2c77bfbbf51bd@syzkaller.appspotmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Alexandre Chartre <alexandre.chartre@oracle.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [syzbot] upstream boot error: WARNING in __context_tracking_enter
Date: Mon, 22 Mar 2021 17:22:41 +0000	[thread overview]
Message-ID: <20210322172241.GB80352@C02TD0UTHF1T.local> (raw)
In-Reply-To: <20210319101043.GU1463@shell.armlinux.org.uk>

Hi Russell,

On Fri, Mar 19, 2021 at 10:10:43AM +0000, Russell King - ARM Linux admin wrote:
> On Fri, Mar 19, 2021 at 10:54:48AM +0100, Dmitry Vyukov wrote:
> > .On Fri, Mar 19, 2021 at 10:44 AM syzbot
> > <syzbot+f09a12b2c77bfbbf51bd@syzkaller.appspotmail.com> wrote:
> > > syzbot found the following issue on:
> > >
> > > HEAD commit:    8b12a62a Merge tag 'drm-fixes-2021-03-19' of git://anongit..
> > > git tree:       upstream
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=17e815aed00000
> > > kernel config:  https://syzkaller.appspot.com/x/.config?x=cfeed364fc353c32
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=f09a12b2c77bfbbf51bd
> > > userspace arch: arm
> > >
> > > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > > Reported-by: syzbot+f09a12b2c77bfbbf51bd@syzkaller.appspotmail.com
> > 
> > 
> > +Mark, arm
> > It did not get far with CONFIG_CONTEXT_TRACKING_FORCE (kernel doesn't boot).
> 
> It seems that the path:
> 
> context_tracking_user_enter()
> user_enter()
> context_tracking_enter()
> __context_tracking_enter()
> vtime_user_enter()
> 
> expects preemption to be disabled. It effectively is, because local
> interrupts are disabled by context_tracking_enter().
> 
> However, the requirement for preemption to be disabled is not
> documented... so shrug. Maybe someone can say what the real requirements
> are here.

From dealing with this recently on arm64, theis is a bit messy. To
handle this robustly we need to do a few things in sequence, including
using the *_irqoff() variants of the context_tracking_user_*()
functions.

I wrote down the constraints in commit:
  
  23529049c6842382 ("arm64: entry: fix non-NMI user<->kernel transitions")

For user->kernel transitions, the arch code needs the following sequence
before invoking arbitrary kernel C code:

	lockdep_hardirqs_off(CALLER_ADDR0);
	user_exit_irqoff();
	trace_hardirqs_off_finish();

For kernel->user transitions, the arch code needs the following sequence
once it will no longer invoke arbitrary kernel C code, just before
returning to userspace:

	trace_hardirqs_on_prepare();
	lockdep_hardirqs_on_prepare(CALLER_ADDR0);
	user_enter_irqoff();
	lockdep_hardirqs_on(CALLER_ADDR0);

Thanks,
Mark.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-03-22 17:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19  9:44 [syzbot] upstream boot error: WARNING in __context_tracking_enter syzbot
2021-03-19  9:54 ` Dmitry Vyukov
2021-03-19  9:54   ` Dmitry Vyukov
2021-03-19 10:10   ` Russell King - ARM Linux admin
2021-03-19 10:10     ` Russell King - ARM Linux admin
2021-03-22 17:22     ` Mark Rutland [this message]
2021-03-22 17:22       ` Mark Rutland
2021-04-13  5:14       ` Dmitry Vyukov
2021-04-13  5:14         ` Dmitry Vyukov
2021-11-10  9:08         ` Marco Elver
2021-11-10  9:08           ` Marco Elver

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=20210322172241.GB80352@C02TD0UTHF1T.local \
    --to=mark.rutland@arm.com \
    --cc=alexandre.chartre@oracle.com \
    --cc=arnd@arndb.de \
    --cc=dvyukov@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mhiramat@kernel.org \
    --cc=peterz@infradead.org \
    --cc=syzbot+f09a12b2c77bfbbf51bd@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tglx@linutronix.de \
    /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.