Skip to content

Commit f7d92f1

Browse files
iangehckuba-moo
authored andcommitted
net: nfc: nci: Fix zero-length proprietary notifications
NCI NFC controllers may have proprietary OIDs with zero-length payload. One example is: drivers/nfc/nxp-nci/core.c, NXP_NCI_RF_TXLDO_ERROR_NTF. Allow a zero length payload in proprietary notifications *only*. Before: -- >8 -- kernel: nci: nci_recv_frame: len 3 -- >8 -- After: -- >8 -- kernel: nci: nci_recv_frame: len 3 kernel: nci: nci_ntf_packet: NCI RX: MT=ntf, PBF=0, GID=0x1, OID=0x23, plen=0 kernel: nci: nci_ntf_packet: unknown ntf opcode 0x123 kernel: nfc nfc0: NFC: RF transmitter couldn't start. Bad power and/or configuration? -- >8 -- After fixing the hardware: -- >8 -- kernel: nci: nci_recv_frame: len 27 kernel: nci: nci_ntf_packet: NCI RX: MT=ntf, PBF=0, GID=0x1, OID=0x5, plen=24 kernel: nci: nci_rf_intf_activated_ntf_packet: rf_discovery_id 1 -- >8 -- Fixes: d24b035 ("nfc: nci: Fix uninit-value in nci_dev_up and nci_ntf_packet") Signed-off-by: Ian Ray <ian.ray@gehealthcare.com> Link: https://patch.msgid.link/20260302163238.140576-1-ian.ray@gehealthcare.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 165573e commit f7d92f1

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

net/nfc/nci/core.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,10 +1482,20 @@ static bool nci_valid_size(struct sk_buff *skb)
14821482
unsigned int hdr_size = NCI_CTRL_HDR_SIZE;
14831483

14841484
if (skb->len < hdr_size ||
1485-
!nci_plen(skb->data) ||
14861485
skb->len < hdr_size + nci_plen(skb->data)) {
14871486
return false;
14881487
}
1488+
1489+
if (!nci_plen(skb->data)) {
1490+
/* Allow zero length in proprietary notifications (0x20 - 0x3F). */
1491+
if (nci_opcode_oid(nci_opcode(skb->data)) >= 0x20 &&
1492+
nci_mt(skb->data) == NCI_MT_NTF_PKT)
1493+
return true;
1494+
1495+
/* Disallow zero length otherwise. */
1496+
return false;
1497+
}
1498+
14891499
return true;
14901500
}
14911501

0 commit comments

Comments
 (0)