From: Simon Horman <horms@kernel.org>
To: Aamir Ahmed <elb12345@hotmail.co.uk>
Cc: David Heidelberg <david@ixit.cz>,
linux-nfc@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] nfc: digital: check DEP_REQ length before reading DID byte
Date: Thu, 10 Sep 2026 10:55:08 +0100 [thread overview]
Message-ID: <20260910095508.GS40544@horms.kernel.org> (raw)
In-Reply-To: <AS8P251MB000196084524EB27D62162B8C8B32@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM>
On Mon, Sep 07, 2026 at 12:36:54AM +0100, Aamir Ahmed wrote:
> digital_tg_recv_dep_req() reads resp->data[3] when the DID bit is set
> in the PFB, but only sizeof(struct digital_dep_req_res) bytes (3) are
> guaranteed by the preceding length check. A crafted DEP_REQ that is
> exactly 3 bytes long with the DID bit set causes an out-of-bounds read
> past the valid skb data.
>
> This read can happen on every DEP_REQ from a malicious NFC initiator
> when the target device has a non-zero DID. The stale byte is compared
> against ddev->did, so in practice the mismatch causes an -EIO return,
> but the read itself is undefined behavior and accesses data past the
> buffer.
>
> Reorder the condition so that the length check (resp->len < size + 1)
> comes first and short-circuits before resp->data[size] is accessed.
> The existing fallthrough to the later "size > resp->len" check is
> preserved for the NAD case.
>
> Fixes: 1c7a4c24fbfd ("NFC Digital: Add target NFC-DEP support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk>
This patch looks good to me but as noted collectively by Greg and Paolo
elsewhere:
1. Please include an Assisted-by tag
2. Please keep the number of patches in-flight to 15 or less
When you repost feel free to include:
Reviewed-by: Simon Horman <horms@kernel.org>
--
pw-bot: changes-requested
prev parent reply other threads:[~2026-09-10 9:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 23:36 [PATCH] nfc: digital: check DEP_REQ length before reading DID byte Aamir Ahmed
2026-09-10 9:55 ` Simon Horman [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=20260910095508.GS40544@horms.kernel.org \
--to=horms@kernel.org \
--cc=david@ixit.cz \
--cc=elb12345@hotmail.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfc@lists.linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.