From: "Lekë Hapçiu" <snowwlake@icloud.com>
To: netdev@vger.kernel.org
Cc: linux-wireless@vger.kernel.org, stable@vger.kernel.org,
krzysztof.kozlowski@linaro.org,
"Lekë Hapçiu" <snowwlake@icloud.com>
Subject: [PATCH net 4/4] nfc: digital: Fix OOB read of DID byte in digital_tg_recv_dep_req()
Date: Fri, 10 Apr 2026 00:34:34 +0200 [thread overview]
Message-ID: <20260409223436.1887988-5-snowwlake@icloud.com> (raw)
In-Reply-To: <20260409223436.1887988-1-snowwlake@icloud.com>
digital_tg_recv_dep_req() guards against short frames with:
if (resp->len < size ...) /* size = sizeof(struct digital_dep_req_res) = 3 */
This guarantees resp->len >= 3 (dir + cmd + pfb). However, when the
DID bit is set in pfb, the code immediately accesses resp->data[3] — the
DID byte — which is one byte past the guaranteed minimum:
if (DIGITAL_NFC_DEP_DID_BIT_SET(pfb)) {
if (ddev->did && (ddev->did == resp->data[3])) {
A remote NFC-DEP initiator can trigger this with a 3-byte DEP_REQ frame
that has the DID bit set in the PFB field, causing a 1-byte
out-of-bounds read of kernel heap memory.
Increment the minimum required length to 4 when the DID bit is present
before accessing resp->data[3], mirroring the pattern used for the
size++ / check at the end of the DID block.
Fixes: 7d0911c07b44 ("NFC Digital: Implement NFC-DEP target TX and RX")
Cc: stable@vger.kernel.org
Signed-off-by: Lekë Hapçiu <snowwlake@icloud.com>
---
net/nfc/digital_dep.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c
index XXXXXXX..XXXXXXX 100644
--- a/net/nfc/digital_dep.c
+++ b/net/nfc/digital_dep.c
@@ -1117,6 +1117,11 @@ static int digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg,
pfb = dep_req->pfb;
if (DIGITAL_NFC_DEP_DID_BIT_SET(pfb)) {
+ if (resp->len < size + 1) {
+ rc = -EIO;
+ goto exit;
+ }
+
if (ddev->did && (ddev->did == resp->data[3])) {
size++;
} else {
--
2.34.1
prev parent reply other threads:[~2026-04-09 22:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 22:34 [PATCH net 0/4] nfc: digital: Fix missing and misplaced length checks Lekë Hapçiu
2026-04-09 22:34 ` [PATCH net 1/4] nfc: digital: Fix stack buffer overflow in digital_in_recv_sensf_res() Lekë Hapçiu
2026-04-12 20:58 ` Jakub Kicinski
2026-04-09 22:34 ` [PATCH net 2/4] nfc: digital: Fix check-after-read in digital_tg_recv_sens_req() Lekë Hapçiu
2026-04-09 22:34 ` [PATCH net 3/4] nfc: digital: Fix OOB read of RTOX byte in digital_in_recv_dep_res() Lekë Hapçiu
2026-04-09 22:34 ` Lekë Hapçiu [this message]
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=20260409223436.1887988-5-snowwlake@icloud.com \
--to=snowwlake@icloud.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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