Linux USB
 help / color / mirror / Atom feed
From: Jeremy Kerr <jk@codeconstruct.com.au>
To: Matt Johnston <matt@codeconstruct.com.au>,
	Andrew Lunn	 <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet	 <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni	 <pabeni@redhat.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v5 00/12] net: mctp: usb: Add support for MCTP-over-USB v1.1
Date: Mon, 27 Jul 2026 10:18:53 +0800	[thread overview]
Message-ID: <a97d01ccf39389d52e70c32c60da5d80ecac2652.camel@codeconstruct.com.au> (raw)
In-Reply-To: <20260724-dev-mctp-usb-1-1-v5-0-e66bbba0dbdc@codeconstruct.com.au>

Hi all,

Some review feedback from sashiko, along with responses:

> --- Patch [2]: [PATCH net-next v5 02/12] net: mctp: usb: Use packet-length max for maximum packet-size check ---
> commit df3ce01edadf3abe9a5e04b1500317e960abd98f
> Author: Jeremy Kerr <jk@codeconstruct.com.au>
> 
> net: mctp: usb: Use packet-length max for maximum packet-size check
> 
> This commit updates the maximum packet size check in mctp-usb to use a new
> define based on the u8 transport header length field. It also applies this
> new maximum to the MTU calculation.
> 
> > diff --git a/drivers/net/mctp/mctp-usb.c b/drivers/net/mctp/mctp-usb.c
> > index 545eff06322ce..c6e36b63e87a0 100644
> > --- a/drivers/net/mctp/mctp-usb.c
> > +++ b/drivers/net/mctp/mctp-usb.c
> > @@ -76,7 +76,7 @@ static netdev_tx_t mctp_usb_start_xmit(struct sk_buff *skb,
> >  
> >  	plen = skb->len;
> >  
> > -	if (plen + sizeof(*hdr) > MCTP_USB_1_0_XFER_SIZE)
> > +	if (plen + sizeof(*hdr) > MCTP_USB_1_0_PKTLEN_MAX)
> >  		goto err_drop;
> >  
> >  	rc = skb_cow_head(skb, sizeof(*hdr));
> 
> This isn't a bug introduced by this patch, but could a transient USB error
> during TX permanently stall the network device's transmit queue?

This is a shortcoming in the existing tx path, and is addressed by patch
05/12.

[...]

> This is also a pre-existing issue, but does the RX polling loop stop
> permanently on transient USB errors?

... and this by patch 04/12.


> --- Patch [5]: [PATCH net-next v5 05/12] net: mctp: usblib: Move TX transfer processing to mctp-usblib ---
> commit ee53d6679c1c34404c4b886475dd086d680df184
> Author: Jeremy Kerr <jk@codeconstruct.com.au>
> 
> net: mctp: usblib: Move TX transfer processing to mctp-usblib
> 
> This commit moves the TX processing alongside RX processing in mctp-usblib
> to accommodate packed transfers where a transfer may contain multiple MCTP
> packets. It splits the transmit API into push, send, and complete stages
> and fixes an inconsistency between tx and rx stats.
> 
> > diff --git a/drivers/net/mctp/mctp-usblib.c b/drivers/net/mctp/mctp-usblib.c
> > --- a/drivers/net/mctp/mctp-usblib.c
> > +++ b/drivers/net/mctp/mctp-usblib.c
> [ ... ]
> > +static int mctp_usblib_tx_skb_prepare(struct sk_buff *skb,
> > +				      enum skb_drop_reason *reason)
> > +{
> > +	struct mctp_usb_hdr *hdr;
> > +	unsigned long plen;
> > +	int rc;
> [ ... ]
> > +	hdr = skb_push(skb, sizeof(*hdr));
> > +	if (!hdr) {
> > +		*reason = SKB_DROP_REASON_NOMEM;
> > +		return -ENOMEM;
> > +	}
> > +
> > +	hdr->id = cpu_to_be16(MCTP_USB_DMTF_ID);
> > +	hdr->rsvd = 0;
> > +	hdr->len = plen + sizeof(*hdr);
> 
> This isn't a bug introduced by this patch, but does this assignment miss a
> cpu_to_be16() conversion?
> 
> The len field in struct mctp_usb_hdr is defined as __be16, but it appears to
> be assigned a native integer value here.

At this point in the series, hdr->len is a u8, not __be16.

We change this to a __be16 two patches later in 07/12, and at the same
time add the necessary endian conversion to all uses of hdr->len.

> --- Patch [10]: [PATCH net-next v5 10/12] net: mctp: usblib: Add initial kunit tests ---
> commit 6e78640ea8bf2b13bb32c513ae1e30a04bebf125
> Author: Jeremy Kerr <jk@codeconstruct.com.au>
> 
> net: mctp: usblib: Add initial kunit tests
> 
> This commit adds initial KUnit tests for the MCTP USB library receive
> path to verify extraction of MCTP packets from incoming USB transfer data.
> 
> > diff --git a/drivers/net/mctp/mctp-usblib-test.c b/drivers/net/mctp/mctp-usblib-test.c
> > new file mode 100644
> > --- /dev/null
> > +++ b/drivers/net/mctp/mctp-usblib-test.c
> 
> [ ... ]
> 
> > +static int mctp_usblib_test_dst_output(struct mctp_dst *dst,
> > +				       struct sk_buff *skb)
> > +{
> > +	struct mctp_usblib_test_dev *dev = netdev_priv(skb->dev);
> > +
> > +	skb_queue_tail(&dev->rx_pkts, skb);
> > +
> > +	return 0;
> > +}
> 
> Could this lead to memory corruption if an external packet is routed here?

This is testcase code, so intentionally simplified, and typically
running within the kunit harness. We should not be receiving or routing
external packets at this point.

Cheers,


Jeremy

      parent reply	other threads:[~2026-07-27  2:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  5:15 [PATCH net-next v5 00/12] net: mctp: usb: Add support for MCTP-over-USB v1.1 Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 01/12] net: mctp: usb: Include version indicator in max packet size defines Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 02/12] net: mctp: usb: Use packet-length max for maximum packet-size check Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 03/12] net: mctp: usblib: Move RX transfer processing to a new mctp-usblib Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 04/12] net: mctp: usb: Improve IN endpoint status handling Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 05/12] net: mctp: usblib: Move TX transfer processing to mctp-usblib Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 06/12] net: mctp: usblib: Add support for multi-packet transmit Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 07/12] net: mctp: usb: Accommodate DSP0283 v1.1 header format Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 08/12] net: mctp: usblib: Implement receive-side packet spanning Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 09/12] net: mctp: usblib: Implement transmit-side " Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 10/12] net: mctp: usblib: Add initial kunit tests Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 11/12] net: mctp: usb: enable v1.1 packet spanning Jeremy Kerr
2026-07-24  5:15 ` [PATCH net-next v5 12/12] net: mctp: usb: Allow multiple urbs in flight Jeremy Kerr
2026-07-27  2:18 ` Jeremy Kerr [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=a97d01ccf39389d52e70c32c60da5d80ecac2652.camel@codeconstruct.com.au \
    --to=jk@codeconstruct.com.au \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=matt@codeconstruct.com.au \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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