mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Neeli, Srinivas" <srneeli@amd.com>
To: sashiko-reviews@lists.linux.dev, Srinivas Neeli <srinivas.neeli@amd.com>
Cc: devicetree@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	robh@kernel.org, conor+dt@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 6/8] net: xilinx: tsn: add the endpoint RX data path
Date: Wed, 11 Nov 2026 13:06:47 +0530	[thread overview]
Message-ID: <b28e1ea5-4309-4e50-8097-528163711569@amd.com> (raw)
In-Reply-To: <sashiko-outbox-175444@kernel.org>

Hi,

On 10/17/2026 3:04 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] net: out-of-bounds read of DMA metadata due to missing meta_len check
> --
>
> commit 0ae3124fbc7145cd6d9f2c1314d8d1defc3b13e2
> Author: Srinivas Neeli <srinivas.neeli@amd.com>
>
> net: xilinx: tsn: add the endpoint RX data path
>
> This commit adds the RX data path for the endpoint to start receiving frames.
> It posts RX buffers to the channels and handles inbound frames in a completion
> callback. It also serialises the RX refill process against the interface
> teardown.
>
>> diff --git a/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c b/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c
>> index ab3d6d8cb9440..0a13e04d40575 100644
>> --- a/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c
>> +++ b/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c
> [ ... ]
>> @@ -112,6 +135,181 @@ ep_get_desc(struct xlnx_tsn_ep_dma_chan *xchan, int idx)
>>   	return xchan->skb_ring[idx];
>>   }
>>   
> [ ... ]
>> +static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result)
>> +{
> [ ... ]
>> +	metadata = dmaengine_desc_get_metadata_ptr(skbuf_dma->desc,
>> +						   &meta_len,
>> +						   &meta_max_len);
>> +	if (IS_ERR_OR_NULL(metadata)) {
>> +		if (net_ratelimit())
>> +			dev_warn(ep->dev, "Failed to get RX metadata pointer\n");
>> +
>> +		dev_kfree_skb_any(skb);
>> +		DEV_STATS_INC(ndev, rx_dropped);
>> +		DEV_STATS_INC(ndev, rx_errors);
>> +		goto submit_new;
>> +	}
>> +
>> +	/* MCDMA metadata: [0] = status, [1] = sideband (TID/TDEST/TUSER), [2..] = app */
>> +	tuser = metadata[1] & TSN_TUSER_MASK;
>                   ^^^^^^^^^^^
>
> [Severity: Medium]
> Could this result in an out-of-bounds read if the metadata array is too small?
>
> The driver gets the metadata pointer and its length via meta_len, but it only
> validates the pointer using IS_ERR_OR_NULL(). There isn't a check to see if
> meta_len is large enough before accessing metadata[1].
>
> If the DMA hardware or backend driver provides fewer than 8 bytes of metadata,
> reading from metadata[1] might result in an out-of-bounds access. Should
> there be a check that meta_len is at least 2 * sizeof(u32) before accessing
> the array?
   The length is fixed by the provider rather than by the frame. For MCDMA
   xilinx_dma_get_metadata_ptr() returns

     *max_len = *payload_len = sizeof(seg->hw.s2mm_status) +
sizeof(seg->hw.s2mm_sideband_status) +
                               sizeof(seg->hw.app);

   which is 28 bytes, and the pointer starts at the status word, so index 1
   is the sideband word and is always in range. A shorter payload is not
   reachable, and the earlier IS_ERR_OR_NULL() already covers the case 
where
   the provider attaches no metadata_ops at all.

Thanks
Srinivas Neeli


  reply	other threads:[~2026-11-11  7:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  9:31 [PATCH net-next v3 0/8] Add Xilinx TSN Endpoint Ethernet MAC driver Srinivas Neeli
2026-10-16  9:32 ` [PATCH net-next v3 1/8] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC Srinivas Neeli
2026-10-20 11:58   ` netdev-bot+sashiko
2026-10-21  3:16     ` Rob Herring
2026-11-03 12:40       ` Neeli, Srinivas
2026-10-16  9:32 ` [PATCH net-next v3 2/8] net: xilinx: tsn: add TSN endpoint wrapper driver Srinivas Neeli
2026-10-20 11:58   ` netdev-bot+sashiko
2026-10-16  9:32 ` [PATCH net-next v3 3/8] net: xilinx: tsn: add endpoint MAC driver skeleton Srinivas Neeli
2026-10-20 11:58   ` netdev-bot+sashiko
2026-10-16  9:32 ` [PATCH net-next v3 4/8] net: xilinx: tsn: parse endpoint DMA channel configuration Srinivas Neeli
2026-10-20 11:58   ` netdev-bot+sashiko
2026-10-16  9:32 ` [PATCH net-next v3 5/8] net: xilinx: tsn: bring up the endpoint MCDMA channels Srinivas Neeli
2026-10-20 11:58   ` netdev-bot+sashiko
2026-11-03 13:55     ` Neeli, Srinivas
2026-10-16  9:32 ` [PATCH net-next v3 6/8] net: xilinx: tsn: add the endpoint RX data path Srinivas Neeli
2026-10-17  9:34   ` sashiko-bot
2026-11-11  7:36     ` Neeli, Srinivas [this message]
2026-10-20 11:58   ` netdev-bot+sashiko
2026-10-16  9:32 ` [PATCH net-next v3 7/8] net: xilinx: tsn: add the endpoint TX " Srinivas Neeli
2026-10-17  9:34   ` sashiko-bot
2026-10-20 11:58   ` netdev-bot+sashiko
2026-10-16  9:32 ` [PATCH net-next v3 8/8] net: xilinx: tsn: deliver endpoint RX frames to DSA user ports Srinivas Neeli
2026-10-20 11:58   ` netdev-bot+sashiko
2026-11-11  7:33     ` Neeli, Srinivas

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=b28e1ea5-4309-4e50-8097-528163711569@amd.com \
    --to=srneeli@amd.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=srinivas.neeli@amd.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®