The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: elver@google.com, gregkh@linuxfoundation.org,
	jirislaby@kernel.org, linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com,
	syzbot <syzbot+5f47a8cea6a12b77a876@syzkaller.appspotmail.com>
Subject: Re: [syzbot] BUG: sleeping function called from invalid context in __might_resched
Date: Tue, 16 Nov 2021 10:03:12 +0100	[thread overview]
Message-ID: <7655311.pJQ0NNsvTN@localhost.localdomain> (raw)
In-Reply-To: <5631140.hc6UrLtR2d@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1660 bytes --]

On Tuesday, November 16, 2021 9:53:53 AM CET Fabio M. De Francesco wrote:
> On Tuesday, November 16, 2021 9:09:11 AM CET syzbot wrote:
> > Hello,
> > 
> > syzbot has tested the proposed patch but the reproducer is still 
triggering 
> an issue:
> > BUG: sleeping function called from invalid context in __might_resched
> > [...]
> 
> The reproducer is still triggering an issue, but this time it looks like it 
> is triggered by a different path of execution.
> 
> The same invalid "in_interrupt()" test is also in con_flush_chars().
> 
> Let's try to remove it too...
> 
> My first idea would be to replace "if (in_interrupt())" with the same 
> "preempt_count() || irqs_disabled()" I used in do_con_write(). However I 
> noticed that both do_con_write() and con_flush_chars() are only called from 
> inside con_write() (which, aside from calling those functions, does nothing 
> else).
> 
> So why not remove the if (in_interrupt()) from both them and use if 
> (preempt_count() || irqs_disabled()) just once in con_write()?
> 
> I think this should be the right solution, but I prefer to go one step at a 
> time.
> 
> Therefore, I'll (1) use the same (redundant, if it was used in con_write()) 
> test also in con_flush_chars(), (2) wait for Syzbot to confirm that it 
fixes 
> the bug, and (3) wait for maintainers review and suggestions about whether 
or 
> not moving those tests one level upper.
> 
> #syz test:
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> 
> ---
> Fabio M. De Francesco

Don't know exactly what happened, so let's retry the test...

#syz test: 
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

[-- Attachment #2: vt.c.diff --]
[-- Type: text/x-patch, Size: 684 bytes --]

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 7359c3e80d63..46511d1ac6ee 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -2902,7 +2902,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
 	struct vt_notifier_param param;
 	bool rescan;
 
-	if (in_interrupt())
+	if (preempt_count() || irqs_disabled())
 		return count;
 
 	console_lock();
@@ -3358,7 +3358,7 @@ static void con_flush_chars(struct tty_struct *tty)
 {
 	struct vc_data *vc;
 
-	if (in_interrupt())	/* from flush_to_ldisc */
+	if (preempt_count() || irqs_disabled())	/* from flush_to_ldisc */
 		return;
 
 	/* if we race with con_close(), vt may be null */

  parent reply	other threads:[~2021-11-16  9:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10 10:18 [syzbot] BUG: sleeping function called from invalid context in __might_resched syzbot
2021-11-12 12:22 ` Fabio M. De Francesco
2021-11-12 13:58   ` Marco Elver
2021-11-12 16:05     ` Fabio M. De Francesco
2021-11-12 16:27       ` Marco Elver
2021-11-12 17:15         ` Fabio M. De Francesco
2021-11-13 20:13 ` syzbot
2021-11-16  7:57   ` Fabio M. De Francesco
2021-11-16  8:09     ` syzbot
2021-11-16  8:53       ` Fabio M. De Francesco
2021-11-16  8:55         ` syzbot
2021-11-16  9:03         ` Fabio M. De Francesco [this message]
2021-11-16  9:03           ` syzbot
2021-11-16  9:20           ` syzbot
2021-11-16  9:13         ` Fabio M. De Francesco
2021-11-16  9:38           ` syzbot
2021-11-16 10:24     ` Marco Elver
2021-11-16 11:35       ` Fabio M. De Francesco

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=7655311.pJQ0NNsvTN@localhost.localdomain \
    --to=fmdefrancesco@gmail.com \
    --cc=elver@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+5f47a8cea6a12b77a876@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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