Skip to content

Commit d24b035

Browse files
YsuOSdavem330
authored andcommitted
nfc: nci: Fix uninit-value in nci_dev_up and nci_ntf_packet
syzbot reported the following uninit-value access issue [1][2]: nci_rx_work() parses and processes received packet. When the payload length is zero, each message type handler reads uninitialized payload and KMSAN detects this issue. The receipt of a packet with a zero-size payload is considered unexpected, and therefore, such packets should be silently discarded. This patch resolved this issue by checking payload size before calling each message type handler codes. Fixes: 6a2968a ("NFC: basic NCI protocol implementation") Reported-and-tested-by: [email protected] Reported-and-tested-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=7ea9413ea6749baf5574 [1] Closes: https://syzkaller.appspot.com/bug?extid=29b5ca705d2e0f4a44d2 [2] Signed-off-by: Ryosuke Yasuoka <[email protected]> Reviewed-by: Jeremy Cline <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cba9ffd commit d24b035

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/nfc/nci/core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,11 @@ static void nci_rx_work(struct work_struct *work)
15161516
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
15171517
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
15181518

1519+
if (!nci_plen(skb->data)) {
1520+
kfree_skb(skb);
1521+
break;
1522+
}
1523+
15191524
/* Process frame */
15201525
switch (nci_mt(skb->data)) {
15211526
case NCI_MT_RSP_PKT:

0 commit comments

Comments
 (0)