mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Manush Prajwal <manushprajwal555@gmail.com>
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: axis-fifo: fix underflow of tx_fifo_depth in size check
Date: Tue, 1 Sep 2026 06:35:56 +0200	[thread overview]
Message-ID: <2026090116-jailhouse-arousal-3fc3@gregkh> (raw)
In-Reply-To: <6a964015.7d702ed2.1273e8.5ac0@mx.google.com>

On Tue, Sep 01, 2026 at 08:31:41AM +0530, Manush Prajwal wrote:
> axis_fifo_write() bounds a transmit by checking:
> 
>     words_to_write > (fifo->tx_fifo_depth - 4)
> 
> fifo->tx_fifo_depth is an unsigned int populated directly from the
> devicetree property "xlnx,tx-fifo-depth" in axis_fifo_parse_dt(),
> with no lower-bound validation. If a devicetree ever supplies a
> tx-fifo-depth smaller than 4 (e.g. a malformed or misconfigured DT),
> "tx_fifo_depth - 4" underflows, wrapping to a huge value. The size
> check above then never triggers, silently defeating the exact
> overrun protection the surrounding comment describes: writes far
> larger than the FIFO's real capacity get accepted and passed to the
> hardware, driving it into the "Transmit Packet Overrun Error"
> condition the check exists to prevent.

So this is just a bug in the device tree?

How was this found and tested?

> Validate tx_fifo_depth against the minimum the driver requires at
> devicetree-parse time, matching the existing validation style already
> used in axis_fifo_parse_dt() for the other DT properties.
> 
> Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>
> ---
>  drivers/staging/axis-fifo/axis-fifo.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
> index 3d358f9193523c..dba76fbf5d685a 100644
> --- a/drivers/staging/axis-fifo/axis-fifo.c
> +++ b/drivers/staging/axis-fifo/axis-fifo.c
> @@ -412,6 +412,13 @@ static int axis_fifo_parse_dt(struct axis_fifo *fifo)
>  				   &fifo->tx_fifo_depth);
>  	if (ret)
>  		return ret;
> +	/*
> +	 * axis_fifo_write() computes 'tx_fifo_depth - 4' to bound the size of
> +	 * a transmit; a depth smaller than that underflows the unsigned
> +	 * subtraction and silently disables the overrun check.
> +	 */

Did you forget to add an Assisted-by: tag for this patch?

thanks,

greg k-h

  reply	other threads:[~2026-09-01  4:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  3:01 Manush Prajwal
2026-09-01  4:35 ` Greg KH [this message]
2026-09-01 14:20 Manush Prajwal

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=2026090116-jailhouse-arousal-3fc3@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=manushprajwal555@gmail.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®