From: Chandradhar Kumar <chandradhar.2003@gmail.com>
To: David Heidelberg <david@ixit.cz>,
Samuel Ortiz <sameo@linux.intel.com>,
Michael Thalmeier <michael.thalmeier@hale.at>
Cc: syzbot+93f169a8e7d66864f800@syzkaller.appspotmail.com,
Chandradhar Kumar <chandradhar.2003@gmail.com>,
oe-linux-nfc@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH net] nfc: pn533: fix slab-out-of-bounds read in pn533_recv_frame()
Date: Wed, 14 Oct 2026 14:02:36 +0530 [thread overview]
Message-ID: <20261014083239.144506-1-chandradhar.2003@gmail.com> (raw)
pn533_recv_frame() accesses skb->data to check for ACK frames, dump
the received frame via print_hex_dump_debug(), and validate the frame
without first verifying that skb->len contains enough bytes for the
frame header and payload. When a short or truncated USB packet is
received, this results in a slab-out-of-bounds read in
hex_dump_to_buffer() or during frame validation.
Fix this by verifying that skb->len is at least PN533_STD_FRAME_ACK_SIZE
before checking for an ACK frame, passing skb->len instead of the
unvalidated rx_frame_size() to print_hex_dump_debug(), and validating
that skb->len is large enough to hold the frame header and complete
frame before calling rx_is_frame_valid().
Fixes: 9815c7cf22da ("NFC: pn533: Separate physical layer from the core implementation")
Reported-by: syzbot+93f169a8e7d66864f800@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=93f169a8e7d66864f800
Signed-off-by: Chandradhar Kumar <chandradhar.2003@gmail.com>
---
drivers/nfc/pn533/pn533.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index b0133e51dce9..c730a84f1c62 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -2193,6 +2193,13 @@ void pn533_recv_frame(struct pn533 *dev, struct sk_buff *skb, int status)
goto sched_wq;
}
+ if (skb->len < PN533_STD_FRAME_ACK_SIZE) {
+ nfc_err(dev->dev, "Received a too short frame\n");
+ dev->cmd->status = -EIO;
+ dev_kfree_skb(skb);
+ goto sched_wq;
+ }
+
if (pn533_rx_frame_is_ack(skb->data)) {
dev_dbg(dev->dev, "%s: Received ACK frame\n", __func__);
dev_kfree_skb(skb);
@@ -2200,9 +2207,12 @@ void pn533_recv_frame(struct pn533 *dev, struct sk_buff *skb, int status)
}
print_hex_dump_debug("PN533 RX: ", DUMP_PREFIX_NONE, 16, 1, skb->data,
- dev->ops->rx_frame_size(skb->data), false);
+ skb->len, false);
- if (!dev->ops->rx_is_frame_valid(skb->data, dev)) {
+ if (skb->len < PN533_STD_FRAME_HEADER_LEN + PN533_STD_FRAME_TAIL_LEN ||
+ skb->len < dev->ops->rx_header_len ||
+ skb->len < dev->ops->rx_frame_size(skb->data) ||
+ !dev->ops->rx_is_frame_valid(skb->data, dev)) {
nfc_err(dev->dev, "Received an invalid frame\n");
dev->cmd->status = -EIO;
} else if (!pn533_rx_frame_is_cmd_response(dev, skb->data)) {
--
2.56.0
reply other threads:[~2026-10-14 8:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261014083239.144506-1-chandradhar.2003@gmail.com \
--to=chandradhar.2003@gmail.com \
--cc=david@ixit.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.thalmeier@hale.at \
--cc=oe-linux-nfc@lists.linux.dev \
--cc=sameo@linux.intel.com \
--cc=syzbot+93f169a8e7d66864f800@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®