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 --- 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