* [PATCH] staging: axis-fifo: fix integer underflow in TX size check
@ 2026-11-02 11:44 Maritu Hone
2026-11-02 12:06 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Maritu Hone @ 2026-11-02 11:44 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel, outreachy-kernel, Maritu Hone
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] staging: axis-fifo: fix integer underflow in TX size check
2026-11-02 11:44 [PATCH] staging: axis-fifo: fix integer underflow in TX size check Maritu Hone
@ 2026-11-02 12:06 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-11-02 12:06 UTC (permalink / raw)
To: Maritu Hone; +Cc: gregkh, linux-staging, linux-kernel, outreachy-kernel
On Mon, Nov 02, 2026 at 02:44:51PM +0300, Maritu Hone wrote:
> 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>
> ---
This patch has been rejected many times before. Best to do a search on
lore.kernel.org before sending patches.
Device trees are trusted. I wonder if the AI is actually searching the
device trees and not finding anything, so it thinks maybe the device
tree is wrong?
$ git grep xlnx,tx-fifo-depth | cat
drivers/staging/axis-fifo/axis-fifo.c: ret = of_property_read_u32(node, "xlnx,tx-fifo-depth",
drivers/staging/axis-fifo/axis-fifo.txt:- xlnx,tx-fifo-depth: Depth of TX FIFO in words
drivers/staging/axis-fifo/axis-fifo.txt: xlnx,tx-fifo-depth = <0x8000>;
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-02 12:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02 11:44 [PATCH] staging: axis-fifo: fix integer underflow in TX size check Maritu Hone
2026-11-02 12:06 ` Dan Carpenter
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®