patch "tty: Don't call panic() at tty_ldisc_init()" added to tty-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
tty: Don't call panic() at tty_ldisc_init()
to my tty git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
in the tty-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
Quoted 1 line
From
903f9db10f18f735e62ba447147b6c434b6af003Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <[email protected]>
Date: Thu, 5 Apr 2018 19:40:16 +0900
Subject: tty: Don't call panic() at tty_ldisc_init()
syzbot is reporting kernel panic [1] triggered by memory allocation failure at tty_ldisc_get() from tty_ldisc_init(). But since both tty_ldisc_get() and caller of tty_ldisc_init() can cleanly handle errors, tty_ldisc_init() does not need to call panic() when tty_ldisc_get() failed.
[1] https://syzkaller.appspot.com/bug?id=883431818e036ae6a9981156a64b821110f39187
--- drivers/tty/tty_io.c | 5 ++++- drivers/tty/tty_ldisc.c | 5 +++-- include/linux/tty.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-)
drivers/tty/tty_io.c +4 -1
@@ -2816,7 +2816,10 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)kref_init (&tty->kref); tty->magic =TTY_MAGIC ; -tty_ldisc_init (tty); +if (tty_ldisc_init (tty)) { +kfree (tty); +return NULL ; + } tty->session =NULL ; tty->pgrp =NULL ;mutex_init (&tty->legacy_mutex);
drivers/tty/tty_ldisc.c +3 -2
@@ -821,12 +821,13 @@ EXPORT_SYMBOL_GPL(tty_ldisc_release);* the tty structure is not completely set up when this call is made. */ -void tty_ldisc_init (struct tty_struct *tty) +int tty_ldisc_init (struct tty_struct *tty) {struct tty_ldisc *ld =tty_ldisc_get (tty,N_TTY );if (IS_ERR (ld)) -panic ("n_tty: init_tty" ); +return PTR_ERR (ld); tty->ldisc = ld; +return 0 ; }/**
include/linux/tty.h +1 -1
@@ -701,7 +701,7 @@ extern int tty_unregister_ldisc(int disc);extern int tty_set_ldisc (struct tty_struct *tty,int disc);extern int tty_ldisc_setup (struct tty_struct *tty,struct tty_struct *o_tty);extern void tty_ldisc_release (struct tty_struct *tty); -extern void tty_ldisc_init (struct tty_struct *tty); +extern int __must_check tty_ldisc_init (struct tty_struct *tty);extern void tty_ldisc_deinit (struct tty_struct *tty);extern int tty_ldisc_receive_buf (struct tty_ldisc *ld,const unsigned char *p,char *f,int count);
Signature · 1 line
2.17.0