From: Jeremy Kerr <jk@codeconstruct.com.au>
To: Adam Young <admiyo@os.amperecomputing.com>,
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>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Sudeep Holla <sudeep.holla@arm.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Huisong Li <lihuisong@huawei.com>
Subject: Re: [net-next v33 1/1] mctp pcc: Implement MCTP over PCC Transport
Date: Tue, 17 Mar 2026 12:51:27 +0800 [thread overview]
Message-ID: <73277cce3afbc784f3aeed69da3c39a0659d562f.camel@codeconstruct.com.au> (raw)
In-Reply-To: <20260316035626.363698-2-admiyo@os.amperecomputing.com>
Hi Adam,
Some comments inline.
> +static void mctp_pcc_client_rx_callback(struct mbox_client *cl, void *mssg)
> +{
> + struct acpi_pcct_ext_pcc_shared_memory pcc_header;
> + struct mctp_pcc_ndev *mctp_pcc_ndev;
> + struct mctp_pcc_mailbox *inbox;
> + struct mctp_skb_cb *cb;
> + struct sk_buff *skb;
> + int size;
> +
> + mctp_pcc_ndev = container_of(cl, struct mctp_pcc_ndev, inbox.client);
> + inbox = &mctp_pcc_ndev->inbox;
> + memcpy_fromio(&pcc_header, inbox->chan->shmem, sizeof(pcc_header));
> + size = pcc_header.length - sizeof(u32);
Since size is signed, this may be negative...
(also, why sizeof(u32) here? from the spec, it seems like you're
trimming the signature here, so MCTP_SIGNATURE_LENGTH would be more
appropriate? or sizeof(pcc_header.command)?)
> +
> + if (size == 0)
> + return;
... which won't get picked up here
> +
> + if (strncmp((unsigned char *)&pcc_header.command, MCTP_SIGNATURE, 4) != 0) {
> + dev_dstats_rx_dropped(mctp_pcc_ndev->ndev);
> + return;
> + }
We shouldn't really be treating the signature as a string, just memcmp()
instead of strncmp(). You could also consider using a u32 (appropriately
commented) instead of the string for MCTP_SIGNATURE, and doing a direct
comparison with pcc_header.command.
4 -> MCTP_SIGNATURE_LENGTH, or whatever you chose for the above.
> +
> + if (size > mctp_pcc_ndev->ndev->mtu)
> + dev_dbg(cl->dev, "MCTP_PCC bytes available exceeds MTU");
(I assume we're fine to receive larger-than-MTU packets, in which
case probably don't need the dev_dbg?)
> +
> + skb = netdev_alloc_skb(mctp_pcc_ndev->ndev, size);
... with the negative size, this will end up as a huge attempted
allocation here.
Maybe change the above check for pcc_header.length > sizeof(whatever),
instead of subtracting the sizeof() first, so you cannot underflow.
Then, use an unsigned type for size.
> + if (!skb) {
> + dev_dstats_rx_dropped(mctp_pcc_ndev->ndev);
> + return;
> + }
> + skb_put(skb, size);
> + skb->protocol = htons(ETH_P_MCTP);
> + memcpy_fromio(skb->data, inbox->chan->shmem + sizeof(pcc_header),
> + size);
Minor: This seems oddly-wrapped, as you have longer lines above.
> + dev_dstats_rx_add(mctp_pcc_ndev->ndev, skb->len);
Your RX stats do not include the PCC header, but your TX stats do.
I would suggest making the SKB layout consistent (ie., presence of the
transport header) across TX and RX. Include the pcc header in
the RX skb data (which you do in the TX path), and use skb->len for both
TX and RX accounting.
Cheers,
Jeremy
next prev parent reply other threads:[~2026-03-17 4:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 3:56 [net-next v33 0/1] MCTP Over PCC Transport Adam Young
2026-03-16 3:56 ` [net-next v33 1/1] mctp pcc: Implement MCTP over " Adam Young
2026-03-16 23:20 ` Adam Young
2026-03-17 4:51 ` Jeremy Kerr [this message]
2026-03-17 19:08 ` Adam Young
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=73277cce3afbc784f3aeed69da3c39a0659d562f.camel@codeconstruct.com.au \
--to=jk@codeconstruct.com.au \
--cc=Jonathan.Cameron@huawei.com \
--cc=admiyo@os.amperecomputing.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=lihuisong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeconstruct.com.au \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sudeep.holla@arm.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