linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kernel BUG at drivers/tty/tty_ldisc.c:LINE!
@ 2018-04-01  8:19 syzbot
  2018-04-25 11:12 ` [PATCH] tty: Use __GFP_NOFAIL for tty_ldisc_get() Tetsuo Handa
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2018-04-01  8:19 UTC (permalink / raw)
  To: gregkh, jslaby, linux-kernel, syzkaller-bugs

Hello,

syzbot hit the following crash on upstream commit
c2a9838452a4d71f76103c18c926468a9ea05713 (Fri Mar 30 05:27:12 2018 +0000)
Merge tag 'for-4.16/dm-fixes-4' of  
git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
syzbot dashboard link:  
https://syzkaller.appspot.com/bug?extid=40b7287c2dc987c48c81

So far this crash happened 2 times on upstream.
Unfortunately, I don't have any reproducer for this crash yet.
Raw console output:  
https://syzkaller.appspot.com/x/log.txt?id=4558686131322880
Kernel config:  
https://syzkaller.appspot.com/x/.config?id=-8440362230543204781
compiler: gcc (GCC) 7.1.1 20170620

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+40b7287c2dc987c48c81@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for  
details.
If you forward the report, please keep this part and the footer.

RDX: 0000000000000000 RSI: 0000000000005441 RDI: 0000000000000014
RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000016
R13: 0000000000000307 R14: 00000000006f6948 R15: 0000000000000002
------------[ cut here ]------------
kernel BUG at drivers/tty/tty_ldisc.c:684!
invalid opcode: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
    (ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 15418 Comm: syz-executor4 Not tainted 4.16.0-rc7+ #6
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
RIP: 0010:tty_ldisc_reinit+0x236/0x2b0 drivers/tty/tty_ldisc.c:684
RSP: 0018:ffff8801d8cdf660 EFLAGS: 00010246
RAX: 0000000000010000 RBX: ffff8801acc871c0 RCX: ffffffff82f49786
RDX: 0000000000010000 RSI: ffffc90001bc1000 RDI: 0000000000000282
RBP: ffff8801d8cdf688 R08: 1ffff1003b19be8c R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: fffffffffffffff4
R13: ffff8801acc87620 R14: 0000000000000000 R15: ffff8801b4a63390
FS:  00007f0cd4482700(0000) GS:ffff8801db200000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b9bc22000 CR3: 00000001cb19e004 CR4: 00000000001606f0
DR0: 0000000020000000 DR1: 0000000020000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000600
Call Trace:
  tty_reopen+0x1a3/0x220 drivers/tty/tty_io.c:1272
  tty_open_by_driver drivers/tty/tty_io.c:1953 [inline]
  tty_open+0x877/0xaa0 drivers/tty/tty_io.c:2007
  chrdev_open+0x257/0x730 fs/char_dev.c:417
  do_dentry_open+0x667/0xd40 fs/open.c:752
  vfs_open+0x107/0x220 fs/open.c:866
  dentry_open+0x9a/0x1f0 fs/open.c:883
  ptm_open_peer+0x20b/0x2f0 drivers/tty/pty.c:639
  tty_ioctl+0x517/0x1610 drivers/tty/tty_io.c:2639
  vfs_ioctl fs/ioctl.c:46 [inline]
  do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
  SYSC_ioctl fs/ioctl.c:701 [inline]
  SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
  do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
  entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x4548b9
RSP: 002b:00007f0cd4481c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f0cd44826d4 RCX: 00000000004548b9
RDX: 0000000000000000 RSI: 0000000000005441 RDI: 0000000000000014
RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000016
R13: 0000000000000307 R14: 00000000006f6948 R15: 0000000000000002
Code: 02 00 0f 85 84 00 00 00 48 c7 83 b0 00 00 00 00 00 00 00 e9 0c fe ff  
ff e8 a8 31 7d fe 45 85 f6 0f 85 f9 fd ff ff e8 9a 31 7d fe <0f> 0b 4c 89  
ef e8 40 78 b5 fe e9 43 fe ff ff 4c 89 ef e8 33 78
RIP: tty_ldisc_reinit+0x236/0x2b0 drivers/tty/tty_ldisc.c:684 RSP:  
ffff8801d8cdf660
---[ end trace 1dab10d0b8df769a ]---


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzkaller@googlegroups.com.

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is  
merged
into any tree, please reply to this email with:
#syz fix: exact-commit-title
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug  
report.
Note: all commands must start from beginning of the line in the email body.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] tty: Use __GFP_NOFAIL for tty_ldisc_get()
  2018-04-01  8:19 kernel BUG at drivers/tty/tty_ldisc.c:LINE! syzbot
@ 2018-04-25 11:12 ` Tetsuo Handa
  2018-04-25 13:00   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Tetsuo Handa @ 2018-04-25 11:12 UTC (permalink / raw)
  To: syzbot, syzkaller-bugs, Michal Hocko
  Cc: linux-kernel, Vegard Nossum, Dmitry Vyukov, Greg Kroah-Hartman,
	Jiri Slaby, Peter Hurley, One Thousand Gnomes, Linus Torvalds

From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

syzbot is reporting crashes triggered by memory allocation fault injection
at tty_ldisc_get() [1]. As an attempt to handle OOM in a graceful way, we
have tried commit 5362544bebe85071 ("tty: don't panic on OOM in
tty_set_ldisc()"). But we reverted that attempt by commit a8983d01f9b7d600
("Revert "tty: don't panic on OOM in tty_set_ldisc()"") due to reproducible
crash. We should spend resource for finding and fixing race condition bugs
rather than complicate error paths for 2 * sizeof(void *) bytes allocation
failure.

[1] https://syzkaller.appspot.com/bug?id=489d33fa386453859ead58ff5171d43772b13aa3

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzbot+40b7287c2dc987c48c81@syzkaller.appspotmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: stable <stable@vger.kernel.org>
---
 drivers/tty/tty_ldisc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 050f4d6..971a37e 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -176,12 +176,11 @@ static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
 			return ERR_CAST(ldops);
 	}
 
-	ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL);
-	if (ld == NULL) {
-		put_ldops(ldops);
-		return ERR_PTR(-ENOMEM);
-	}
-
+	/*
+	 * There is no way to handle allocation failure of only 16 bytes.
+	 * Let's simplify error handling and save more memory.
+	 */
+	ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL | __GFP_NOFAIL);
 	ld->ops = ldops;
 	ld->tty = tty;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty: Use __GFP_NOFAIL for tty_ldisc_get()
  2018-04-25 11:12 ` [PATCH] tty: Use __GFP_NOFAIL for tty_ldisc_get() Tetsuo Handa
@ 2018-04-25 13:00   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2018-04-25 13:00 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: syzbot, syzkaller-bugs, Michal Hocko, linux-kernel,
	Vegard Nossum, Dmitry Vyukov, Jiri Slaby, Peter Hurley,
	One Thousand Gnomes, Linus Torvalds

On Wed, Apr 25, 2018 at 08:12:31PM +0900, Tetsuo Handa wrote:
> From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> 
> syzbot is reporting crashes triggered by memory allocation fault injection
> at tty_ldisc_get() [1]. As an attempt to handle OOM in a graceful way, we
> have tried commit 5362544bebe85071 ("tty: don't panic on OOM in
> tty_set_ldisc()"). But we reverted that attempt by commit a8983d01f9b7d600
> ("Revert "tty: don't panic on OOM in tty_set_ldisc()"") due to reproducible
> crash. We should spend resource for finding and fixing race condition bugs
> rather than complicate error paths for 2 * sizeof(void *) bytes allocation
> failure.
> 
> [1] https://syzkaller.appspot.com/bug?id=489d33fa386453859ead58ff5171d43772b13aa3
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Reported-by: syzbot <syzbot+40b7287c2dc987c48c81@syzkaller.appspotmail.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Vegard Nossum <vegard.nossum@gmail.com>
> Cc: Dmitry Vyukov <dvyukov@google.com>
> Cc: Jiri Slaby <jslaby@suse.com>
> Cc: Peter Hurley <peter@hurleysoftware.com>
> Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: stable <stable@vger.kernel.org>
> ---
>  drivers/tty/tty_ldisc.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
> index 050f4d6..971a37e 100644
> --- a/drivers/tty/tty_ldisc.c
> +++ b/drivers/tty/tty_ldisc.c
> @@ -176,12 +176,11 @@ static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
>  			return ERR_CAST(ldops);
>  	}
>  
> -	ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL);
> -	if (ld == NULL) {
> -		put_ldops(ldops);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -
> +	/*
> +	 * There is no way to handle allocation failure of only 16 bytes.
> +	 * Let's simplify error handling and save more memory.
> +	 */
> +	ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL | __GFP_NOFAIL);
>  	ld->ops = ldops;
>  	ld->tty = tty;
>  

Yes, this is the thing to do, thanks, I'll go queue this up now.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-25 13:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-01  8:19 kernel BUG at drivers/tty/tty_ldisc.c:LINE! syzbot
2018-04-25 11:12 ` [PATCH] tty: Use __GFP_NOFAIL for tty_ldisc_get() Tetsuo Handa
2018-04-25 13:00   ` Greg Kroah-Hartman

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).