netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Heidelberg <david@ixit.cz>
To: Muhammad Bilal <meatuni001@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	oe-linux-nfc@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH net v2] nfc: nci: fix use of uninitialized memory in NFC-DEP general bytes
Date: Sun, 19 Jul 2026 17:27:49 +0200	[thread overview]
Message-ID: <b8433f37-374d-4764-a3c2-119375d0e309@ixit.cz> (raw)
In-Reply-To: <20260628214929.135152-1-meatuni001@gmail.com>

On 28/06/2026 23:49, Muhammad Bilal wrote:
> nci_store_general_bytes_nfc_dep() derives the length of the NFC-DEP
> general bytes by subtracting the fixed general-bytes offset from the ATR
> length:
> 
>    atr_res_len - NFC_ATR_RES_GT_OFFSET   (poll, offset 15)
>    atr_req_len - NFC_ATR_REQ_GT_OFFSET   (listen, offset 14)
> 
> It never checks that the ATR is at least that long.  When a
> RF_INTF_ACTIVATED_NTF reports an ATR shorter than the offset the
> subtraction is negative; because min_t() casts its arguments to __u8 the
> negative value becomes large and is then capped at
> NFC_ATR_RES_GB_MAXSIZE / NFC_ATR_REQ_GB_MAXSIZE.  remote_gb_len is thus
> set to up to 47/48 even though only atr_res_len/atr_req_len bytes of the
> on-stack atr_res/atr_req buffer were copied from the packet, and the
> following memcpy() reads the uninitialized remainder into
> ndev->remote_gb.
> 
> Zero remote_gb_len and skip storing the general bytes when the ATR is
> shorter than the general-bytes offset, so that a stale remote_gb_len
> from a previous activation does not survive into the new session.
> 
> Fixes: a99903ec4566 ("NFC: NCI: Handle Target mode activation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
> ---
>   net/nfc/nci/ntf.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
Hello Muhammad,

could you please rebase the patch on the currect version for-linus or for-next?

Thank you
David

  reply	other threads:[~2026-07-19 15:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-28 21:49 [PATCH net v2] nfc: nci: fix use of uninitialized memory in NFC-DEP general bytes Muhammad Bilal
2026-07-19 15:27 ` David Heidelberg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-06-28 21:16 [PATCH net] " Muhammad Bilal
2026-06-28 21:45 ` [PATCH net v2] " Muhammad Bilal

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=b8433f37-374d-4764-a3c2-119375d0e309@ixit.cz \
    --to=david@ixit.cz \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=meatuni001@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=oe-linux-nfc@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --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;
as well as URLs for NNTP newsgroup(s).