linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Laurent Dufour <ldufour@linux.vnet.ibm.com>,
	Andrew Morton <akpm@osdl.org>,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] sched: Do not bug in __sched_setscheduler() when pi is not used
Date: Mon, 19 Nov 2018 11:35:37 -0500	[thread overview]
Message-ID: <20181119113537.3aa4f05e@gandalf.local.home> (raw)
In-Reply-To: <20181119162432.GB13065@kroah.com>

On Mon, 19 Nov 2018 17:24:32 +0100
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Mon, Nov 19, 2018 at 10:46:54AM -0500, Steven Rostedt wrote:
> > On Mon, 19 Nov 2018 16:13:11 +0100
> > Greg KH <gregkh@linuxfoundation.org> wrote:
> >   
> > > > Can this patch also be applied to the stable trees? The offending commit
> > > > was first introduced in 4.2.    
> > > 
> > > What is the git commit id of this patch in Linus's tree?  
> > 
> > 896bbb2522587e3b8eb2a0d204d43ccc1042a00d
> > 
> > The subject was changed when it was applied.  
> 
> Ah, that helps.
> 
> But why is this really needed in the older kernels?  You want to crash
> your machine if someone got things wrong?  Given that I doubt this is
> being hit anymore, why is it needed in 4.9.y and 4.4.y?

The problem is that it can crash when people didn't get it wrong (by
using sysrq).

The bug happened when we combined two functions into one, and where the
BUG_ON() from one was now added to the other function. The one (where
pi is true) requires the function to be called with interrupts
disabled. The other did not have this requirement (and pi happens to be
false). Thus, you can trigger the BUG_ON(in_interrupt()) with a simple
sysrq key stroke, and crash your kernel when it did nothing wrong.

> 
> Also, it doesn't apply there so someone needs to do the backport...
> 

I did the change against v4.2.8 below.

-- Steve

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 6776631676e0..b2af7989eb5b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3682,7 +3682,7 @@ static int __sched_setscheduler(struct task_struct *p,
 	int reset_on_fork;
 
 	/* may grab non-irq protected spin_locks */
-	BUG_ON(in_interrupt());
+	BUG_ON(pi && in_interrupt());
 recheck:
 	/* double check policy once rq lock held */
 	if (policy < 0) {

  reply	other threads:[~2018-11-19 16:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-09 15:18 [PATCH] sched: Do not bug in __sched_setscheduler() when pi is not used Steven Rostedt
2017-05-16 22:55 ` Steven Rostedt
2017-05-17  6:56   ` Peter Zijlstra
2018-11-14 20:55 ` Florian Fainelli
2018-11-19 15:13   ` Greg KH
2018-11-19 15:46     ` Steven Rostedt
2018-11-19 16:24       ` Greg KH
2018-11-19 16:35         ` Steven Rostedt [this message]
2018-11-19 19:09           ` Florian Fainelli
2018-11-19 19:27             ` Steven Rostedt
2018-11-29 12:23               ` Greg KH

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=20181119113537.3aa4f05e@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@osdl.org \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ldufour@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --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 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).