Skip to content

Commit b7ac893

Browse files
XidianGeneraldavem330
authored andcommitted
net: nfc: nci: fix a possible sleep-in-atomic-context bug in nci_uart_tty_receive()
The kernel may sleep while holding a spinlock. The function call path (from bottom to top) in Linux 4.19 is: net/nfc/nci/uart.c, 349: nci_skb_alloc in nci_uart_default_recv_buf net/nfc/nci/uart.c, 255: (FUNC_PTR)nci_uart_default_recv_buf in nci_uart_tty_receive net/nfc/nci/uart.c, 254: spin_lock in nci_uart_tty_receive nci_skb_alloc(GFP_KERNEL) can sleep at runtime. (FUNC_PTR) means a function pointer is called. To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC for nci_skb_alloc(). This bug is found by a static analysis tool STCheck written by myself. Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ddd9b5e commit b7ac893

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎net/nfc/nci/uart.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static int nci_uart_default_recv_buf(struct nci_uart *nu, const u8 *data,
346346
nu->rx_packet_len = -1;
347347
nu->rx_skb = nci_skb_alloc(nu->ndev,
348348
NCI_MAX_PACKET_SIZE,
349-
GFP_KERNEL);
349+
GFP_ATOMIC);
350350
if (!nu->rx_skb)
351351
return -ENOMEM;
352352
}

0 commit comments

Comments
 (0)