From: sashiko-bot@kernel.org
To: "Jaegyun Lee" <dreams200260@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH 1/2] usb: gadget: f_ncm: drop datagrams larger than the NTB
Date: Sun, 29 Nov 2026 13:43:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-239640@kernel.org> (raw)
In-Reply-To: <20261129133609.403044-1-dreams200260@gmail.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] usb: gadget: f_ncm: shared SKB corruption in ncm_wrap_ntb()
[1]
--
commit 948568907c84c75cecfaf30bb2740fb5aec595d7
Author: Jaegyun Lee <dreams200260@gmail.com>
usb: gadget: f_ncm: drop datagrams larger than the NTB
This commit drops outgoing datagrams in ncm_wrap_ntb() when a single
datagram is too large to fit into an empty NTB of the host-selected
input size.
> diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
> index 87a217090968b..da8fe49d625a2 100644
> --- a/drivers/usb/gadget/function/f_ncm.c
> +++ b/drivers/usb/gadget/function/f_ncm.c
> @@ -1030,6 +1030,14 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
> put_unaligned_le32(crc, crc_pos);
> }
>
> + if (ALIGN(ALIGN(opts->nth_size, div) + rem + skb->len,
> + ndp_align) + opts->ndp_size + 2 * dgram_idx_len >
> + max_size) {
> + skb->dev->stats.tx_dropped++;
> + dev_kfree_skb_any(skb);
> + return NULL;
> + }
> +
> /* If the new skb is too big for the current NCM NTB then
> * set the current stored skb to be sent now and clear it
> * ready for new data.
[Severity: Critical]
This problem wasn't introduced by this patch, but when ncm->is_crc is
enabled via USB_CDC_SET_CRC_MODE, can appending the CRC right above
this check corrupt a shared skb or panic on insufficient tailroom
[1]?
drivers/usb/gadget/function/f_ncm.c:ncm_wrap_ntb() {
...
if (ncm->is_crc) {
uint32_t crc;
__le16 *crc_pos;
crc = ~crc32_le(~0,
skb->data,
skb->len);
crc_pos = skb_put(skb, sizeof(uint32_t));
put_unaligned_le32(crc, crc_pos);
}
...
}
The driver does not set needed_tailroom on the net_device or call
skb_cow_head() / skb_unshare() before calling skb_put() on the incoming
skb. Mutating a cloned or shared skb corrupts payload data for other
users such as TCP retransmissions, and calling skb_put() without 4 bytes
of tailroom triggers skb_over_panic().
[1] https://sashiko.dev/#/bug/linux-702bf875-b704-4d4a-b11e-f29c6932077d
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129133609.403044-1-dreams200260@gmail.com?part=1
next prev parent reply other threads:[~2026-11-29 13:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 13:36 [PATCH 1/2] usb: gadget: f_ncm: drop datagrams larger than the NTB Jaegyun Lee
2026-11-29 13:36 ` [PATCH 2/2] usb: gadget: f_ncm: check pending NTB tailroom before appending Jaegyun Lee
2026-11-29 13:43 ` sashiko-bot [this message]
2026-11-29 13:45 ` [PATCH 1/2] usb: gadget: f_ncm: drop datagrams larger than the NTB sashiko-bot
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=sashiko-outbox-239640@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dreams200260@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.