Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: n_gsm: fix sleep-in-atomic-context bug in gsm_control_send

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: e1eaea46bb40 ("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>

authored by

Duoming Zhou and committed by
Greg Kroah-Hartman
7b7dfe48 15743ae5

+1 -1
+1 -1
drivers/tty/n_gsm.c
··· 1711 1711 unsigned int command, u8 *data, int clen) 1712 1712 { 1713 1713 struct gsm_control *ctrl = kzalloc(sizeof(struct gsm_control), 1714 - GFP_KERNEL); 1714 + GFP_ATOMIC); 1715 1715 unsigned long flags; 1716 1716 if (ctrl == NULL) 1717 1717 return NULL;