From: Maritu Hone <marehone12@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
outreachy-kernel@googlegroups.com,
Maritu Hone <marehone12@gmail.com>
Subject: [PATCH] staging: axis-fifo: fix integer underflow in TX size check
Date: Mon, 2 Nov 2026 14:44:51 +0300 [thread overview]
Message-ID: <20261102114451.54579-1-marehone12@gmail.com> (raw)
fifo->tx_fifo_depth is an unsigned int parsed from the devicetree
property "xlnx,tx-fifo-depth" with no lower-bound validation. The
write() packet-size check subtracts 4 from it:
words_to_write > (fifo->tx_fifo_depth - 4)
If tx_fifo_depth is less than 4, this subtraction underflows and
wraps around to a value near UINT_MAX, so the check that is supposed
to reject oversized writes never triggers, regardless of how large
words_to_write actually is.
Reject the write up front when tx_fifo_depth is below the minimum
required by the hardware, before the subtraction can underflow.
Fixes: 52ff2b840bc7 ("staging: axis-fifo: fix maximum TX packet length check")
Signed-off-by: Maritu Hone <marehone12@gmail.com>
---
drivers/staging/axis-fifo/axis-fifo.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index 7bb35e11d1dd..aa76be5d78e4 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -228,6 +228,7 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
* raised, which requires a reset of the TX circuit to recover.
*/
if (!words_to_write || (len % sizeof(u32)) ||
+ fifo->tx_fifo_depth < 4 ||
(words_to_write > (fifo->tx_fifo_depth - 4)))
return -EINVAL;
--
2.43.0
next reply other threads:[~2026-11-02 11:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 11:44 Maritu Hone [this message]
2026-11-02 12:06 ` Dan Carpenter
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=20261102114451.54579-1-marehone12@gmail.com \
--to=marehone12@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=outreachy-kernel@googlegroups.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®