From: Huai-Yuan Liu <qq810974084@gmail.com>
To: jes@trained-monkey.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com
Cc: linux-hippi@sunsite.dk, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, baijiaju1990@gmail.com,
Huai-Yuan Liu <qq810974084@gmail.com>
Subject: [PATCH V2] hippi: fix possible buffer overflow caused by bad DMA value in rr_start_xmit()
Date: Thu, 20 Jun 2024 20:23:11 +0800 [thread overview]
Message-ID: <20240620122311.424811-1-qq810974084@gmail.com> (raw)
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.
---
drivers/net/hippi/rrunner.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index aa8f828a0ae7..6b0056ced922 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -1440,6 +1440,11 @@ 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);
+ 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
next reply other threads:[~2024-06-20 12:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 12:23 Huai-Yuan Liu [this message]
2024-06-21 5:11 ` [PATCH V2] hippi: fix possible buffer overflow caused by bad DMA value in rr_start_xmit() Sunil Kovvuri Goutham
2024-06-21 15:34 ` Jakub Kicinski
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=20240620122311.424811-1-qq810974084@gmail.com \
--to=qq810974084@gmail.com \
--cc=baijiaju1990@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jes@trained-monkey.org \
--cc=kuba@kernel.org \
--cc=linux-hippi@sunsite.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).