]> git.baikalelectronics.ru Git - kernel.git/commit
tty: n_gsm: fix sleep-in-atomic-context bug in gsm_control_send
authorDuoming Zhou <duoming@zju.edu.cn>
Sun, 2 Oct 2022 04:07:09 +0000 (12:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Nov 2022 16:42:14 +0000 (17:42 +0100)
commit2492bd009b9c0508911a4715fd2426e850cde093
tree7aa9bc49a3c4df5a413b19e2bad81f7ce46b43a2
parenta61e5503f3f34531b72d2c97060dfbdf249c91dc
tty: n_gsm: fix sleep-in-atomic-context bug in gsm_control_send

[ Upstream commit 052128439dbf8886164d90efdbedf8624ebbac3b ]

The function gsm_dlci_t1() is a timer handler that runs in an
atomic context, but it calls "kzalloc(..., GFP_KERNEL)" that
may sleep. As a result, the sleep-in-atomic-context bug will
happen. The process is shown below:

gsm_dlci_t1()
 gsm_dlci_open()
  gsm_modem_update()
   gsm_modem_upd_via_msc()
    gsm_control_send()
     kzalloc(sizeof(.., GFP_KERNEL) //may sleep

This patch changes the gfp_t parameter of kzalloc() from GFP_KERNEL to
GFP_ATOMIC in order to mitigate the bug.

Fixes: 99551fa31543 ("tty: n_gsm line discipline")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Link: https://lore.kernel.org/r/20221002040709.27849-1-duoming@zju.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/n_gsm.c