mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] nfc: digital: fix read of resp->data[0] before length check in sens_req
@ 2026-09-30 22:02 Ömer Mete Kaya
  2026-09-30 22:14 ` netdev-bot+sinfo
  0 siblings, 1 reply; 3+ messages in thread
From: Ömer Mete Kaya @ 2026-09-30 22:02 UTC (permalink / raw)
  To: oe-linux-nfc
  Cc: david, davem, edumazet, kuba, pabeni, horms, netdev,
	linux-kernel, Ömer Mete Kaya

digital_tg_recv_sens_req() reads resp->data[0] into sens_req before
checking !resp->len, so a zero-length response causes a out-of-bounds
read before the guard that was meant to prevent it.

Fix by checking resp->len first and returning -EINVAL early, then
reading resp->data[0] only when the buffer is known non-empty.

Fixes: bf30a67c947e ("NFC: digital: Add tg_listen_md and tg_get_rf_tech driver hooks")
Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>
---
 net/nfc/digital_technology.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/nfc/digital_technology.c b/net/nfc/digital_technology.c
index ae6487c10..b27d45e05 100644
--- a/net/nfc/digital_technology.c
+++ b/net/nfc/digital_technology.c
@@ -1097,10 +1097,15 @@ void digital_tg_recv_sens_req(struct nfc_digital_dev *ddev, void *arg,
 		goto exit;
 	}

+	if (!resp->len) {
+		rc = -EINVAL;
+		goto exit;
+	}
+
 	sens_req = resp->data[0];

-	if (!resp->len || (sens_req != DIGITAL_CMD_SENS_REQ &&
-	    sens_req != DIGITAL_CMD_ALL_REQ)) {
+	if (sens_req != DIGITAL_CMD_SENS_REQ &&
+	    sens_req != DIGITAL_CMD_ALL_REQ) {
 		rc = -EINVAL;
 		goto exit;
 	}
--
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] nfc: digital: fix read of resp->data[0] before length check in sens_req
  2026-09-30 22:02 [PATCH net] nfc: digital: fix read of resp->data[0] before length check in sens_req Ömer Mete Kaya
@ 2026-09-30 22:14 ` netdev-bot+sinfo
  2026-09-30 22:45   ` Ömer Mete Kaya
  0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-09-30 22:14 UTC (permalink / raw)
  To: Ömer Mete Kaya
  Cc: oe-linux-nfc, david, davem, edumazet, kuba, pabeni, horms,
	netdev, linux-kernel

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by code inspection). If it was triggered please include
   the symptoms, like the stack trace or error messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] nfc: digital: fix read of resp->data[0] before length check in sens_req
  2026-09-30 22:14 ` netdev-bot+sinfo
@ 2026-09-30 22:45   ` Ömer Mete Kaya
  0 siblings, 0 replies; 3+ messages in thread
From: Ömer Mete Kaya @ 2026-09-30 22:45 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: oe-linux-nfc, david, davem, edumazet, kuba, pabeni, horms,
	netdev, linux-kernel



On 10/1/26 01:14, netdev-bot+sinfo@kernel.org wrote:
> Hi!
> 
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
> 
>  - How the issue was discovered, e.g. hit in production, hit during
>    development, syzbot report, manual code inspection, LLM or static
>    analysis tool scan.

Manual code inspection.

>  - Whether the issue was actually triggered, or is only theoretical
>    (e.g. found by code inspection). If it was triggered please include
>    the symptoms, like the stack trace or error messages.
> 
It was obvious, I didnt triggered.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-30 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30 22:02 [PATCH net] nfc: digital: fix read of resp->data[0] before length check in sens_req Ömer Mete Kaya
2026-09-30 22:14 ` netdev-bot+sinfo
2026-09-30 22:45   ` Ömer Mete Kaya

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®