]> git.itanic.dy.fi Git - linux-stable/commit
tty: n_gsm: initialize more members at gsm_alloc_mux()
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Sat, 27 Aug 2022 13:47:19 +0000 (22:47 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 Aug 2022 12:35:04 +0000 (14:35 +0200)
commit4bb1a53be85fcb1e24c14860e326a00cdd362c28
treee2d7a9b750c6e4b79b5d46e7b9e7e87c8c2e229d
parentf16c6d2e58a4c2b972efcf9eb12390ee0ba3befb
tty: n_gsm: initialize more members at gsm_alloc_mux()

syzbot is reporting use of uninitialized spinlock at gsmld_write() [1], for
commit 32dd59f96924f45e ("tty: n_gsm: fix race condition in gsmld_write()")
allows accessing gsm->tx_lock before gsm_activate_mux() initializes it.

Since object initialization should be done right after allocation in order
to avoid accessing uninitialized memory, move initialization of
timer/work/waitqueue/spinlock from gsmld_open()/gsm_activate_mux() to
gsm_alloc_mux().

Link: https://syzkaller.appspot.com/bug?extid=cf155def4e717db68a12
Fixes: 32dd59f96924f45e ("tty: n_gsm: fix race condition in gsmld_write()")
Reported-by: syzbot <syzbot+cf155def4e717db68a12@syzkaller.appspotmail.com>
Tested-by: syzbot <syzbot+cf155def4e717db68a12@syzkaller.appspotmail.com>
Cc: stable <stable@kernel.org>
Acked-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Link: https://lore.kernel.org/r/2110618e-57f0-c1ce-b2ad-b6cacef3f60e@I-love.SAKURA.ne.jp
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_gsm.c