Messages in this thread Patch in this message | | | From | "Fabio M. De Francesco" <> | Subject | [PATCH] vt: Fix sleeping functions called from atomic context | Date | Tue, 16 Nov 2021 15:49:37 +0100 |
| |
Fix two sleeping functions called from atomic context by doing immediate return to the caller if !preemptible() evaluates 'true'. Remove two in_interrupt() tests because they are not suited for being used here.
Since functions do_con_write() and con_flush_chars() might sleep in console_lock(), it must be assured that they are never executed in atomic contexts.
This issue is reported by Syzbot which notices that they are executed while holding spinlocks and with interrupts disabled. Actually Syzbot emits a first report and then, after fixing do_con_write(), a second report for the same problem in con_flush_chars() because these functions are called one after the other by con_write().
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: syzbot+5f47a8cea6a12b77a876@syzkaller.appspotmail.com Suggested-by: Marco Elver <elver@google.com> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> --- drivers/tty/vt/vt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 7359c3e80d63..508f8a56d361 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 (!preemptible()) 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 (!preemptible()) /* from flush_to_ldisc */ return; /* if we race with con_close(), vt may be null */ -- 2.33.1
| |