* Re: [syzbot] [PATCH net] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
@ 2024-04-05 7:11 ` syzbot
2024-04-05 15:28 ` syzbot
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-04-05 7:11 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 58c806d867bf265c6fd16fc3bc62e2d3c156b5c9
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 0d26c8ec9993..b7a020484131 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1516,7 +1516,7 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!skb->len || !nci_plen(skb->data)) {
kfree_skb(skb);
break;
}
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
2024-04-05 7:11 ` [syzbot] [PATCH net] nfc: nci: Fix " syzbot
@ 2024-04-05 15:28 ` syzbot
2024-04-05 15:46 ` syzbot
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-04-05 15:28 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 58c806d867bf265c6fd16fc3bc62e2d3c156b5c9
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 0d26c8ec9993..b7a020484131 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1516,7 +1516,7 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!skb->len || !nci_plen(skb->data)) {
kfree_skb(skb);
break;
}
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
2024-04-05 7:11 ` [syzbot] [PATCH net] nfc: nci: Fix " syzbot
2024-04-05 15:28 ` syzbot
@ 2024-04-05 15:46 ` syzbot
2024-04-05 15:50 ` syzbot
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-04-05 15:46 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 58c806d867bf265c6fd16fc3bc62e2d3c156b5c9
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index cdad47b140fa..b7a020484131 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1516,6 +1516,11 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
+ if (!skb->len || !nci_plen(skb->data)) {
+ kfree_skb(skb);
+ break;
+ }
+
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (2 preceding siblings ...)
2024-04-05 15:46 ` syzbot
@ 2024-04-05 15:50 ` syzbot
2024-04-25 2:55 ` [syzbot] [PATCH net v2] " syzbot
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-04-05 15:50 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 0d26c8ec9993..b7a020484131 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1516,7 +1516,7 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!skb->len || !nci_plen(skb->data)) {
kfree_skb(skb);
break;
}
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v2] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (3 preceding siblings ...)
2024-04-05 15:50 ` syzbot
@ 2024-04-25 2:55 ` syzbot
2024-04-25 2:55 ` syzbot
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-04-25 2:55 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v2] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 0d26c8ec9993..ab07b5f69664 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,16 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb, unsigned int header_size)
+{
+ if (skb->len < header_size ||
+ !nci_plen(skb->data) ||
+ skb->len < header_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,30 +1526,36 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
- kfree_skb(skb);
- break;
- }
+ if (!skb->len)
+ goto invalid_pkt_free;
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ goto invalid_pkt_free;
nci_rsp_packet(ndev, skb);
break;
case NCI_MT_NTF_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ goto invalid_pkt_free;
nci_ntf_packet(ndev, skb);
break;
case NCI_MT_DATA_PKT:
+ if (!nci_valid_size(skb, NCI_DATA_HDR_SIZE))
+ goto invalid_pkt_free;
nci_rx_data_packet(ndev, skb);
break;
default:
pr_err("unknown MT 0x%x\n", nci_mt(skb->data));
- kfree_skb(skb);
- break;
+ goto invalid_pkt_free;
}
+invalid_pkt_free:
+ kfree_skb(skb);
+ break;
}
/* check if a data exchange timeout has occurred */
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v2] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (4 preceding siblings ...)
2024-04-25 2:55 ` [syzbot] [PATCH net v2] " syzbot
@ 2024-04-25 2:55 ` syzbot
2024-05-01 18:00 ` [syzbot] [PATCH net v3] " syzbot
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-04-25 2:55 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v2] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 0d26c8ec9993..ab07b5f69664 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,16 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb, unsigned int header_size)
+{
+ if (skb->len < header_size ||
+ !nci_plen(skb->data) ||
+ skb->len < header_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,30 +1526,36 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
- kfree_skb(skb);
- break;
- }
+ if (!skb->len)
+ goto invalid_pkt_free;
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ goto invalid_pkt_free;
nci_rsp_packet(ndev, skb);
break;
case NCI_MT_NTF_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ goto invalid_pkt_free;
nci_ntf_packet(ndev, skb);
break;
case NCI_MT_DATA_PKT:
+ if (!nci_valid_size(skb, NCI_DATA_HDR_SIZE))
+ goto invalid_pkt_free;
nci_rx_data_packet(ndev, skb);
break;
default:
pr_err("unknown MT 0x%x\n", nci_mt(skb->data));
- kfree_skb(skb);
- break;
+ goto invalid_pkt_free;
}
+invalid_pkt_free:
+ kfree_skb(skb);
+ break;
}
/* check if a data exchange timeout has occurred */
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v3] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (5 preceding siblings ...)
2024-04-25 2:55 ` syzbot
@ 2024-05-01 18:00 ` syzbot
2024-05-02 5:26 ` syzbot
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-01 18:00 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v3] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 0d26c8ec9993..e4f92a090022 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,16 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb, unsigned int header_size)
+{
+ if (skb->len < header_size ||
+ !nci_plen(skb->data) ||
+ skb->len < header_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,30 +1526,35 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
- kfree_skb(skb);
- break;
- }
+ if (!skb->len)
+ goto invalid_pkt_free;
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ goto invalid_pkt_free;
nci_rsp_packet(ndev, skb);
- break;
+ continue;
case NCI_MT_NTF_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ goto invalid_pkt_free;
nci_ntf_packet(ndev, skb);
- break;
+ continue;
case NCI_MT_DATA_PKT:
+ if (!nci_valid_size(skb, NCI_DATA_HDR_SIZE))
+ goto invalid_pkt_free;
nci_rx_data_packet(ndev, skb);
- break;
+ continue;
default:
pr_err("unknown MT 0x%x\n", nci_mt(skb->data));
- kfree_skb(skb);
- break;
+ goto invalid_pkt_free;
}
+invalid_pkt_free:
+ kfree_skb(skb);
}
/* check if a data exchange timeout has occurred */
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v3] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (6 preceding siblings ...)
2024-05-01 18:00 ` [syzbot] [PATCH net v3] " syzbot
@ 2024-05-02 5:26 ` syzbot
2024-05-08 15:08 ` [syzbot] [PATCH net v4] " syzbot
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-02 5:26 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v3] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e88c4cfcb7b888ac374916806f86c17d8ecaeb67
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 0d26c8ec9993..e4f92a090022 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,16 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb, unsigned int header_size)
+{
+ if (skb->len < header_size ||
+ !nci_plen(skb->data) ||
+ skb->len < header_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,30 +1526,35 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
- kfree_skb(skb);
- break;
- }
+ if (!skb->len)
+ goto invalid_pkt_free;
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ goto invalid_pkt_free;
nci_rsp_packet(ndev, skb);
- break;
+ continue;
case NCI_MT_NTF_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ goto invalid_pkt_free;
nci_ntf_packet(ndev, skb);
- break;
+ continue;
case NCI_MT_DATA_PKT:
+ if (!nci_valid_size(skb, NCI_DATA_HDR_SIZE))
+ goto invalid_pkt_free;
nci_rx_data_packet(ndev, skb);
- break;
+ continue;
default:
pr_err("unknown MT 0x%x\n", nci_mt(skb->data));
- kfree_skb(skb);
- break;
+ goto invalid_pkt_free;
}
+invalid_pkt_free:
+ kfree_skb(skb);
}
/* check if a data exchange timeout has occurred */
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (7 preceding siblings ...)
2024-05-02 5:26 ` syzbot
@ 2024-05-08 15:08 ` syzbot
2024-05-08 15:16 ` syzbot
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-08 15:08 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git master
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index b133dc55304c..cd2d54168a8e 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,16 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb, unsigned int header_size)
+{
+ if (skb->len < header_size ||
+ !nci_plen(skb->data) ||
+ skb->len < header_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,23 +1526,34 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!skb->len) {
kfree_skb(skb);
- kcov_remote_stop();
- break;
+ continue;
}
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE)) {
+ kfree_skb(skb);
+ break;
+ }
nci_rsp_packet(ndev, skb);
break;
case NCI_MT_NTF_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE)) {
+ kfree_skb(skb);
+ break;
+ }
nci_ntf_packet(ndev, skb);
break;
case NCI_MT_DATA_PKT:
+ if (!nci_valid_size(skb, NCI_DATA_HDR_SIZE)) {
+ kfree_skb(skb);
+ break;
+ }
nci_rx_data_packet(ndev, skb);
break;
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (8 preceding siblings ...)
2024-05-08 15:08 ` [syzbot] [PATCH net v4] " syzbot
@ 2024-05-08 15:16 ` syzbot
2024-05-09 0:49 ` syzbot
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-08 15:16 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git master
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index b133dc55304c..0aaff30cb68f 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,16 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb, unsigned int header_size)
+{
+ if (skb->len < header_size ||
+ !nci_plen(skb->data) ||
+ skb->len < header_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,24 +1526,32 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!skb->len) {
kfree_skb(skb);
- kcov_remote_stop();
- break;
+ continue;
}
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
- nci_rsp_packet(ndev, skb);
+ if (nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ nci_rsp_packet(ndev, skb);
+ else
+ kfree_skb(skb);
break;
case NCI_MT_NTF_PKT:
- nci_ntf_packet(ndev, skb);
+ if (nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ nci_ntf_packet(ndev, skb);
+ else
+ kfree_skb(skb);
break;
case NCI_MT_DATA_PKT:
- nci_rx_data_packet(ndev, skb);
+ if (nci_valid_size(skb, NCI_DATA_HDR_SIZE))
+ nci_rx_data_packet(ndev, skb);
+ else
+ kfree_skb(skb);
break;
default:
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (9 preceding siblings ...)
2024-05-08 15:16 ` syzbot
@ 2024-05-09 0:49 ` syzbot
2024-05-09 0:51 ` syzbot
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-09 0:49 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git main
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index b133dc55304c..0aaff30cb68f 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,16 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb, unsigned int header_size)
+{
+ if (skb->len < header_size ||
+ !nci_plen(skb->data) ||
+ skb->len < header_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,24 +1526,32 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!skb->len) {
kfree_skb(skb);
- kcov_remote_stop();
- break;
+ continue;
}
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
- nci_rsp_packet(ndev, skb);
+ if (nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ nci_rsp_packet(ndev, skb);
+ else
+ kfree_skb(skb);
break;
case NCI_MT_NTF_PKT:
- nci_ntf_packet(ndev, skb);
+ if (nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ nci_ntf_packet(ndev, skb);
+ else
+ kfree_skb(skb);
break;
case NCI_MT_DATA_PKT:
- nci_rx_data_packet(ndev, skb);
+ if (nci_valid_size(skb, NCI_DATA_HDR_SIZE))
+ nci_rx_data_packet(ndev, skb);
+ else
+ kfree_skb(skb);
break;
default:
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (10 preceding siblings ...)
2024-05-09 0:49 ` syzbot
@ 2024-05-09 0:51 ` syzbot
2024-05-09 4:07 ` syzbot
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-09 0:51 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git main
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index b133dc55304c..cd2d54168a8e 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,16 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb, unsigned int header_size)
+{
+ if (skb->len < header_size ||
+ !nci_plen(skb->data) ||
+ skb->len < header_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,23 +1526,34 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!skb->len) {
kfree_skb(skb);
- kcov_remote_stop();
- break;
+ continue;
}
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE)) {
+ kfree_skb(skb);
+ break;
+ }
nci_rsp_packet(ndev, skb);
break;
case NCI_MT_NTF_PKT:
+ if (!nci_valid_size(skb, NCI_CTRL_HDR_SIZE)) {
+ kfree_skb(skb);
+ break;
+ }
nci_ntf_packet(ndev, skb);
break;
case NCI_MT_DATA_PKT:
+ if (!nci_valid_size(skb, NCI_DATA_HDR_SIZE)) {
+ kfree_skb(skb);
+ break;
+ }
nci_rx_data_packet(ndev, skb);
break;
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (11 preceding siblings ...)
2024-05-09 0:51 ` syzbot
@ 2024-05-09 4:07 ` syzbot
2024-05-19 5:02 ` [syzbot] [PATCH net v5] " syzbot
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-09 4:07 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git main
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index b133dc55304c..0aaff30cb68f 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,16 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb, unsigned int header_size)
+{
+ if (skb->len < header_size ||
+ !nci_plen(skb->data) ||
+ skb->len < header_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,24 +1526,32 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!skb->len) {
kfree_skb(skb);
- kcov_remote_stop();
- break;
+ continue;
}
/* Process frame */
switch (nci_mt(skb->data)) {
case NCI_MT_RSP_PKT:
- nci_rsp_packet(ndev, skb);
+ if (nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ nci_rsp_packet(ndev, skb);
+ else
+ kfree_skb(skb);
break;
case NCI_MT_NTF_PKT:
- nci_ntf_packet(ndev, skb);
+ if (nci_valid_size(skb, NCI_CTRL_HDR_SIZE))
+ nci_ntf_packet(ndev, skb);
+ else
+ kfree_skb(skb);
break;
case NCI_MT_DATA_PKT:
- nci_rx_data_packet(ndev, skb);
+ if (nci_valid_size(skb, NCI_DATA_HDR_SIZE))
+ nci_rx_data_packet(ndev, skb);
+ else
+ kfree_skb(skb);
break;
default:
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v5] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (12 preceding siblings ...)
2024-05-09 4:07 ` syzbot
@ 2024-05-19 5:02 ` syzbot
2024-05-19 6:42 ` syzbot
2024-05-19 8:39 ` syzbot
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-19 5:02 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v5] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git master
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index b133dc55304c..7a9897fbf4f4 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,19 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb)
+{
+ BUILD_BUG_ON(NCI_CTRL_HDR_SIZE != NCI_DATA_HDR_SIZE);
+ unsigned int hdr_size = NCI_CTRL_HDR_SIZE;
+
+ if (skb->len < hdr_size ||
+ !nci_plen(skb->data) ||
+ skb->len < hdr_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,7 +1529,7 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!nci_valid_size(skb)) {
kfree_skb(skb);
kcov_remote_stop();
break;
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v5] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (13 preceding siblings ...)
2024-05-19 5:02 ` [syzbot] [PATCH net v5] " syzbot
@ 2024-05-19 6:42 ` syzbot
2024-05-19 8:39 ` syzbot
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-19 6:42 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v5] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git main
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index b133dc55304c..7a9897fbf4f4 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,19 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb)
+{
+ BUILD_BUG_ON(NCI_CTRL_HDR_SIZE != NCI_DATA_HDR_SIZE);
+ unsigned int hdr_size = NCI_CTRL_HDR_SIZE;
+
+ if (skb->len < hdr_size ||
+ !nci_plen(skb->data) ||
+ skb->len < hdr_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,7 +1529,7 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!nci_valid_size(skb)) {
kfree_skb(skb);
kcov_remote_stop();
break;
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [syzbot] [PATCH net v5] nfc: nci: Fix uninit-value in nci_rx_work
2024-01-01 13:38 [syzbot] [net?] [nfc?] KMSAN: uninit-value in nci_rx_work syzbot
` (14 preceding siblings ...)
2024-05-19 6:42 ` syzbot
@ 2024-05-19 8:39 ` syzbot
15 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2024-05-19 8:39 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH net v5] nfc: nci: Fix uninit-value in nci_rx_work
Author: ryasuoka@redhat.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git 4db783d68b9b39a411a96096c10828ff5dfada7a
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index b133dc55304c..7a9897fbf4f4 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1463,6 +1463,19 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
ndev->ops->n_core_ops);
}
+static bool nci_valid_size(struct sk_buff *skb)
+{
+ BUILD_BUG_ON(NCI_CTRL_HDR_SIZE != NCI_DATA_HDR_SIZE);
+ unsigned int hdr_size = NCI_CTRL_HDR_SIZE;
+
+ if (skb->len < hdr_size ||
+ !nci_plen(skb->data) ||
+ skb->len < hdr_size + nci_plen(skb->data)) {
+ return false;
+ }
+ return true;
+}
+
/* ---- NCI TX Data worker thread ---- */
static void nci_tx_work(struct work_struct *work)
@@ -1516,7 +1529,7 @@ static void nci_rx_work(struct work_struct *work)
nfc_send_to_raw_sock(ndev->nfc_dev, skb,
RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
- if (!nci_plen(skb->data)) {
+ if (!nci_valid_size(skb)) {
kfree_skb(skb);
kcov_remote_stop();
break;
^ permalink raw reply related [flat|nested] 17+ messages in thread