mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: piyus@iiitd.ac.in
Cc: david@ixit.cz, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
	horms@kernel.org, oe-linux-nfc@lists.linux.dev,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kapil@presceralabs.ai
Subject: Re: [PATCH net v2 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb
Date: Tue, 01 Dec 2026 02:15:39 +0000	[thread overview]
Message-ID: <179609133959.3146.7683414965988508365@kernel.org> (raw)
In-Reply-To: <20261130012208.1962491-2-piyus@iiitd.ac.in>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch leaves a remotely triggerable leak on the path it now
  relies on.
- [Low] The Signed-off-by chain does not match the recorded authorship.

--

net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb

This commit changes the size accumulator in nfc_llcp_allocate_snl() from
u16 to size_t. The SDRES length that nfc_llcp_recv_snl() computes is then
no longer truncated before it reaches alloc_skb(). This prevents the
skb_over_panic() in nfc_llcp_send_snl_sdres() when a peer sends an SNL PDU
with enough SDREQ TLVs to push the total past 65535.

Link: https://lore.kernel.org/netdev/20261123023548.3351531-1-piyus@iiitd.ac.in/

> Signed-off-by: Kapil Vaswani <kapil@presceralabs.ai>
> Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>

[Severity: Low]
This isn't a bug, but the Signed-off-by chain doesn't match the recorded
authorship. The author is Piyus Kedia, but Kapil Vaswani's Signed-off-by
comes first and there is no Co-developed-by tag.

Documentation/process/submitting-patches.rst says the order of the
Signed-off-by tags should reflect the chronological history of the patch.
It also says every Co-developed-by must be immediately followed by the
co-author's Signed-off-by.

If Kapil Vaswani co-developed this, should there be a Co-developed-by tag
for him immediately before his Signed-off-by? If not, should the tags be
reordered, or that one dropped?

> diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c
> index 80a00938c8696..0a3d66e6cd59f 100644
> --- a/net/nfc/llcp_commands.c
> +++ b/net/nfc/llcp_commands.c
> @@ -542,7 +542,7 @@ static struct sk_buff *nfc_llcp_allocate_snl(struct nfc_llcp_local *local,
>  {
>  	struct sk_buff *skb;
>  	struct nfc_dev *dev;
> -	u16 size = 0;
> +	size_t size = 0;

[Severity: High]
With size held in a size_t, the full peer-controlled tlv_length now
reaches alloc_skb(size, GFP_KERNEL). The commit message says:

  A request that large may now fail the allocation instead, which the
  existing IS_ERR() path in both callers already handles.

Is that true for the SDRES caller? If the allocation fails, does
nfc_llcp_send_snl_sdres() leak every entry on tlv_list?

net/nfc/llcp_commands.c:nfc_llcp_send_snl_sdres() {
	...
	skb = nfc_llcp_allocate_snl(local, tlvs_len);
	if (IS_ERR(skb))
		return PTR_ERR(skb);

	hlist_for_each_entry_safe(sdp, n, tlv_list, node) {
		skb_put_data(skb, sdp->tlv, sdp->tlv_len);

		hlist_del(&sdp->node);

		nfc_llcp_free_sdp_tlv(sdp);
	}
	...
}

That loop is the only place the entries are freed, and it only runs when
the allocation succeeds.

The caller ignores the return value. llc_sdres_list is a stack-local
HLIST_HEAD, so it goes out of scope with the entries still linked:

net/nfc/llcp_core.c:nfc_llcp_recv_snl() {
	...
exit:
	...
	if (!hlist_empty(&llc_sdres_list))
		nfc_llcp_send_snl_sdres(local, &llc_sdres_list, sdres_tlvs_len);
}

nfc_llcp_build_sdres_tlv() builds each entry. It allocates the
nfc_llcp_sdp_tlv struct with kzalloc_obj() and the TLV buffer with
nfc_llcp_build_tlv().

For the commit message's 16400-SDREQ example, that is two slab objects per
SDREQ, or roughly 1 MB per failed response. The 65600-byte skb head is a
costly-order allocation that can fail when memory is fragmented. A remote
peer can also send such SNL PDUs repeatedly.

The SDREQ caller does clean up. nfc_genl_llc_sdreq() in net/nfc/netlink.c
calls nfc_llcp_free_sdp_tlv_list() unconditionally at its free_list label,
after nfc_llcp_send_snl_sdreq() returns.

None of the later patches in this series change this path.

Could the IS_ERR() path in nfc_llcp_send_snl_sdres() free tlv_list?
Alternatively, nfc_llcp_recv_snl() could call
nfc_llcp_free_sdp_tlv_list(&llc_sdres_list) after the send. Either way, the
commit message would need updating to match.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130012208.1962491-1-piyus%40iiitd.ac.in

  reply	other threads:[~2026-12-01  2:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  1:22 [PATCH net v2 0/3] net/nfc: three peer-reachable skb bugs in LLCP and NCI Piyus Kedia
2026-11-30  1:22 ` [PATCH net v2 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb Piyus Kedia
2026-12-01  2:15   ` netdev-bot+sashiko [this message]
2026-11-30  1:22 ` [PATCH net v2 2/3] net/nfc: llcp: take the skb reference before queueing it to the socket Piyus Kedia
2026-12-01  2:15   ` netdev-bot+sashiko
2026-11-30  1:22 ` [PATCH net v2 3/3] net/nfc: nci: do not hand a NULL skb to the nfc core Piyus Kedia
2026-12-01  2:15   ` netdev-bot+sashiko

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=179609133959.3146.7683414965988508365@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=david@ixit.cz \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kapil@presceralabs.ai \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oe-linux-nfc@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --cc=piyus@iiitd.ac.in \
    --cc=willemb@google.com \
    /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

all inboxes | Powered by JetHome®