* [PATCH V3] hippi: fix possible buffer overflow caused by bad DMA value in rr_start_xmit()
@ 2024-06-22 6:32 Huai-Yuan Liu
2024-06-22 16:58 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: Huai-Yuan Liu @ 2024-06-22 6:32 UTC (permalink / raw)
To: jes, davem, edumazet, kuba, pabeni
Cc: linux-hippi, netdev, linux-kernel, baijiaju1990, Huai-Yuan Liu
The value rrpriv->info->tx_ctrl is stored in DMA memory, and it is
assigned to txctrl, so txctrl->pi can be modified at any time by malicious
hardware. Becausetxctrl->pi is assigned to index, buffer overflow may
occur when the code "rrpriv->tx_skbuff[index]" is executed.
To address this issue, the index should be checked.
Fixes: f33a7251c825 ("hippi: switch from 'pci_' to 'dma_' API")
Signed-off-by: Huai-Yuan Liu <qq810974084@gmail.com>
---
V2:
* In patch V2, we remove the first condition in if statement and use
netdev_err() instead of printk().
Thanks Paolo Abeni for helpful advice.
V3:
* In patch V3, we stop the queue before return BUSY.
Thanks to Jakub Kicinski for his advice.
---
drivers/net/hippi/rrunner.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index aa8f828a0ae7..f4da342dd5cc 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -1440,6 +1440,12 @@ static netdev_tx_t rr_start_xmit(struct sk_buff *skb,
txctrl = &rrpriv->info->tx_ctrl;
index = txctrl->pi;
+ if (index >= TX_RING_ENTRIES) {
+ netdev_err(dev, "invalid index value %02x\n", index);
+ netif_stop_queue(dev);
+ spin_unlock_irqrestore(&rrpriv->lock, flags);
+ return NETDEV_TX_BUSY;
+ }
rrpriv->tx_skbuff[index] = skb;
set_rraddr(&rrpriv->tx_ring[index].addr,
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH V3] hippi: fix possible buffer overflow caused by bad DMA value in rr_start_xmit()
2024-06-22 6:32 [PATCH V3] hippi: fix possible buffer overflow caused by bad DMA value in rr_start_xmit() Huai-Yuan Liu
@ 2024-06-22 16:58 ` Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2024-06-22 16:58 UTC (permalink / raw)
To: Huai-Yuan Liu, linux-hippi, netdev, David S. Miller,
Eric Dumazet, Jakub Kicinski, Jes Sorensen, Paolo Abeni,
Sunil Kovvuri Goutham
Cc: LKML, Jia-Ju Bai
> …. Becausetxctrl->pi is assigned to …
Word separation?
> To address this issue, the index should be checked.
Can an imperative wording be more desirable for such a change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc4#n94
Regards,
Markus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-22 16:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-22 6:32 [PATCH V3] hippi: fix possible buffer overflow caused by bad DMA value in rr_start_xmit() Huai-Yuan Liu
2024-06-22 16:58 ` Markus Elfring
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®