* [PATCH v2] nfc: pn533: fix OOB read in pn533_acr122_is_rx_frame_valid()
@ 2026-09-12 4:03 Deepanshu Kartikey
2026-09-20 23:11 ` David Heidelberg
0 siblings, 1 reply; 3+ messages in thread
From: Deepanshu Kartikey @ 2026-09-12 4:03 UTC (permalink / raw)
To: david, johan
Cc: kuba, error27, gregkh, sameo, michael.thalmeier, oe-linux-nfc,
linux-kernel, Deepanshu Kartikey, syzbot+1853daab1a47603d4678
frame->ccid.datalen is read directly from the USB response frame
and used, unchecked, as an index into frame->data[]. A malicious or
malfunctioning device can set this field to an arbitrary value,
causing the driver to read far outside the received buffer.
Bound ccid.datalen against the maximum possible ACR122 frame size
before using it. This replaces the existing datalen == 0 check,
since datalen < 2 already covers that case and additionally
rejects datalen == 1, which would still underflow the
"datalen - 2" offset used below.
Fixes: 9815c7cf22da ("NFC: pn533: Separate physical layer from the core implementation")
Reported-by: syzbot+1853daab1a47603d4678@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1853daab1a47603d4678
Tested-by: syzbot+1853daab1a47603d4678@syzkaller.appspotmail.com
Assisted-by: Claude (Anthropic)
Link: https://lore.kernel.org/all/20260906054336.20187-1-kartikey406@gmail.com/T/ [v1]
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
Changes in v2:
- Replace the existing "if (!frame->ccid.datalen)" check instead of
adding the new bounds check alongside it, since the new check
already subsumes it (per Johan Hovold).
---
drivers/nfc/pn533/usb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index efb07f944fce..9471c34b4d4b 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -319,7 +319,9 @@ static bool pn533_acr122_is_rx_frame_valid(void *_frame, struct pn533 *dev)
if (frame->ccid.type != 0x83)
return false;
- if (!frame->ccid.datalen)
+ if (frame->ccid.datalen < 2 ||
+ frame->ccid.datalen > PN533_ACR122_FRAME_MAX_PAYLOAD_LEN +
+ PN533_ACR122_RX_FRAME_TAIL_LEN)
return false;
if (frame->data[frame->ccid.datalen - 2] == 0x63)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] nfc: pn533: fix OOB read in pn533_acr122_is_rx_frame_valid()
2026-09-12 4:03 [PATCH v2] nfc: pn533: fix OOB read in pn533_acr122_is_rx_frame_valid() Deepanshu Kartikey
@ 2026-09-20 23:11 ` David Heidelberg
2026-09-21 0:22 ` Deepanshu Kartikey
0 siblings, 1 reply; 3+ messages in thread
From: David Heidelberg @ 2026-09-20 23:11 UTC (permalink / raw)
To: Deepanshu Kartikey, johan
Cc: kuba, error27, gregkh, sameo, michael.thalmeier, oe-linux-nfc,
linux-kernel, syzbot+1853daab1a47603d4678
On 12/09/2026 06:03, Deepanshu Kartikey wrote:
> frame->ccid.datalen is read directly from the USB response frame
> and used, unchecked, as an index into frame->data[]. A malicious or
> malfunctioning device can set this field to an arbitrary value,
> causing the driver to read far outside the received buffer.
>
> Bound ccid.datalen against the maximum possible ACR122 frame size
> before using it. This replaces the existing datalen == 0 check,
> since datalen < 2 already covers that case and additionally
> rejects datalen == 1, which would still underflow the
> "datalen - 2" offset used below.
>
> Fixes: 9815c7cf22da ("NFC: pn533: Separate physical layer from the core implementation")
> Reported-by: syzbot+1853daab1a47603d4678@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=1853daab1a47603d4678
> Tested-by: syzbot+1853daab1a47603d4678@syzkaller.appspotmail.com
> Assisted-by: Claude (Anthropic)
Hello Deepanshu,
thank you for the patch, could you please correct the Assisted-by tag?
See: https://docs.kernel.org/process/coding-assistants.html
Thanks
David
> Link: https://lore.kernel.org/all/20260906054336.20187-1-kartikey406@gmail.com/T/ [v1]
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
>
> ---
> Changes in v2:
> - Replace the existing "if (!frame->ccid.datalen)" check instead of
> adding the new bounds check alongside it, since the new check
> already subsumes it (per Johan Hovold).
> ---
> drivers/nfc/pn533/usb.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] nfc: pn533: fix OOB read in pn533_acr122_is_rx_frame_valid()
2026-09-20 23:11 ` David Heidelberg
@ 2026-09-21 0:22 ` Deepanshu Kartikey
0 siblings, 0 replies; 3+ messages in thread
From: Deepanshu Kartikey @ 2026-09-21 0:22 UTC (permalink / raw)
To: David Heidelberg
Cc: johan, kuba, error27, gregkh, sameo, michael.thalmeier,
oe-linux-nfc, linux-kernel, syzbot+1853daab1a47603d4678
On Mon, Sep 21, 2026 at 4:41 AM David Heidelberg <david@ixit.cz> wrote:
>
> On 12/09/2026 06:03, Deepanshu Kartikey wrote:
> > frame->ccid.datalen is read directly from the USB response frame
> > and used, unchecked, as an index into frame->data[]. A malicious or
> > malfunctioning device can set this field to an arbitrary value,
> > causing the driver to read far outside the received buffer.
> >
> > Bound ccid.datalen against the maximum possible ACR122 frame size
> > before using it. This replaces the existing datalen == 0 check,
> > since datalen < 2 already covers that case and additionally
> > rejects datalen == 1, which would still underflow the
> > "datalen - 2" offset used below.
> >
> > Fixes: 9815c7cf22da ("NFC: pn533: Separate physical layer from the core implementation")
> > Reported-by: syzbot+1853daab1a47603d4678@syzkaller.appspotmail.com
> > Closes: https://syzkaller.appspot.com/bug?extid=1853daab1a47603d4678
> > Tested-by: syzbot+1853daab1a47603d4678@syzkaller.appspotmail.com
> > Assisted-by: Claude (Anthropic)
>
> Hello Deepanshu,
>
> thank you for the patch, could you please correct the Assisted-by tag?
>
> See: https://docs.kernel.org/process/coding-assistants.html
>
> Thanks
> David
>
Sure, I will send patch v3 shortly.
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-21 0:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-12 4:03 [PATCH v2] nfc: pn533: fix OOB read in pn533_acr122_is_rx_frame_valid() Deepanshu Kartikey
2026-09-20 23:11 ` David Heidelberg
2026-09-21 0:22 ` Deepanshu Kartikey
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®