* [PATCH net-next 0/2] ibmveth: two TX and reset fixes
@ 2026-11-19 0:02 Mingming Cao
2026-11-19 0:02 ` [PATCH net-next 1/2] ibmveth: drop TX on a queue whose long term buffer was freed Mingming Cao
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Mingming Cao @ 2026-11-19 0:02 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, nnac123, maddy, mpe, npiggin, chleroy, ritesh.list,
sshegde, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Two independent bugs in ibmveth that exist on today's kernels.
1. After ethtool -L shrinks the TX queues, a sender that already
picked a removed queue (AF_PACKET PACKET_QDISC_BYPASS, pktgen)
can memcpy into a NULL long-term buffer. Drop that packet, and
stop TX with netif_tx_disable() so a sender already in xmit is
done before ethtool -L allocates or frees a buffer.
2. ibmveth_reset() closes and reopens the device without checking
whether the admin already set it down, and can bring it back up.
Skip the reopen if the device is not running.
Both came up during review of the v8 multi-queue series [1]: patch 1
on v8 06/15, patch 2 while splitting that series. They carry Fixes:
tags, but the triggers are narrow and the second multi-queue series
builds on them, so please take them through net-next. The first
pre-multi-queue series, posted separately, does not depend on them.
Tested: PowerVM LPAR. ethtool -L TX shrink under traffic, ifdown/up
under iperf3, and a queued reset while the admin has set the device
down.
[1] https://lore.kernel.org/netdev/20261109235556.60604-1-mmc@linux.ibm.com/
Mingming Cao (2):
ibmveth: drop TX on a queue whose long term buffer was freed
ibmveth: do not reopen a device that was set down before reset ran
drivers/net/ethernet/ibm/ibmveth.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
base-commit: d6816d9a93b66a12bf01e10037e377f3333ad6cc
--
2.50.1 (Apple Git-155)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/2] ibmveth: drop TX on a queue whose long term buffer was freed
2026-11-19 0:02 [PATCH net-next 0/2] ibmveth: two TX and reset fixes Mingming Cao
@ 2026-11-19 0:02 ` Mingming Cao
2026-11-23 0:44 ` netdev-bot+sashiko
2026-11-19 0:02 ` [PATCH net-next 2/2] ibmveth: do not reopen a device that was set down before reset ran Mingming Cao
2026-11-19 0:07 ` [PATCH net-next 0/2] ibmveth: two TX and reset fixes netdev-bot+sinfo
2 siblings, 1 reply; 6+ messages in thread
From: Mingming Cao @ 2026-11-19 0:02 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, nnac123, maddy, mpe, npiggin, chleroy, ritesh.list,
sshegde, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
ibmveth_set_channels() frees the TX long term buffer (LTB) of every
queue it removes and then wakes all TX queues. A sender that picked
its queue before the shrink, such as AF_PACKET with
PACKET_QDISC_BYPASS or pktgen, can call ibmveth_start_xmit() on a
removed queue after that, and memcpy() into a NULL LTB.
Read the LTB pointer once and drop the packet if it is NULL.
Stop TX with netif_tx_disable() instead of netif_tx_stop_all_queues(),
so a sender already in ibmveth_start_xmit() has left before
set_channels() allocates, maps or frees an LTB. On a grow, that
sender could otherwise see a new LTB before it is DMA mapped, or one
that the failure path frees again.
Fixes: 10c2aba89cc0 ("ibmveth: Ethtool set queue support")
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 05d6b60cd187..faacff14841b 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -599,7 +599,7 @@ static void ibmveth_free_tx_ltb(struct ibmveth_adapter *adapter, int idx)
if (!ptr)
return;
- adapter->tx_ltb_ptr[idx] = NULL;
+ WRITE_ONCE(adapter->tx_ltb_ptr[idx], NULL);
dma_unmap_single(&adapter->vdev->dev, adapter->tx_ltb_dma[idx],
adapter->tx_ltb_size, DMA_TO_DEVICE);
kfree(ptr);
@@ -1195,7 +1195,7 @@ static int ibmveth_set_channels(struct net_device *netdev,
/* We have IBMVETH_MAX_QUEUES netdev_queue's allocated
* but we may need to alloc/free the ltb's.
*/
- netif_tx_stop_all_queues(netdev);
+ netif_tx_disable(netdev);
/* Allocate any queue that we need */
for (i = old; i < goal; i++) {
@@ -1304,6 +1304,16 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,
union ibmveth_buf_desc desc;
int i, queue_num = skb_get_queue_mapping(skb);
unsigned long mss = 0;
+ void *ltb;
+
+ /* A sender that picked its queue before ethtool -L shrank the TX
+ * queues can get here after that queue's LTB was freed.
+ */
+ ltb = READ_ONCE(adapter->tx_ltb_ptr[queue_num]);
+ if (unlikely(!ltb)) {
+ netdev->stats.tx_dropped++;
+ goto out;
+ }
if (ibmveth_is_packet_unsupported(skb, netdev))
goto out;
@@ -1359,13 +1369,13 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,
netdev->stats.tx_dropped++;
goto out;
}
- memcpy(adapter->tx_ltb_ptr[queue_num], skb->data, skb_headlen(skb));
+ memcpy(ltb, skb->data, skb_headlen(skb));
total_bytes = skb_headlen(skb);
/* Copy frags into mapped buffers */
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
- memcpy(adapter->tx_ltb_ptr[queue_num] + total_bytes,
+ memcpy(ltb + total_bytes,
skb_frag_address_safe(frag), skb_frag_size(frag));
total_bytes += skb_frag_size(frag);
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/2] ibmveth: do not reopen a device that was set down before reset ran
2026-11-19 0:02 [PATCH net-next 0/2] ibmveth: two TX and reset fixes Mingming Cao
2026-11-19 0:02 ` [PATCH net-next 1/2] ibmveth: drop TX on a queue whose long term buffer was freed Mingming Cao
@ 2026-11-19 0:02 ` Mingming Cao
2026-11-19 0:07 ` [PATCH net-next 0/2] ibmveth: two TX and reset fixes netdev-bot+sinfo
2 siblings, 0 replies; 6+ messages in thread
From: Mingming Cao @ 2026-11-19 0:02 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, nnac123, maddy, mpe, npiggin, chleroy, ritesh.list,
sshegde, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
ibmveth_reset() runs from a work item queued by the RX, poll and
replenish paths. It calls dev_close() and dev_open() without checking
whether the device is still up. If the admin sets the device down
between queueing the work and the work taking rtnl_lock(), dev_close()
does nothing and dev_open() brings the device back up.
Only close and reopen the device if it is running.
Fixes: 2c91e2319ed9 ("net: ibmveth: Reset the adapter when unexpected states are detected")
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index faacff14841b..34745df8daaa 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -904,8 +904,10 @@ static void ibmveth_reset(struct work_struct *w)
rtnl_lock();
- dev_close(adapter->netdev);
- dev_open(adapter->netdev, NULL);
+ if (netif_running(netdev)) {
+ dev_close(netdev);
+ dev_open(netdev, NULL);
+ }
rtnl_unlock();
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/2] ibmveth: two TX and reset fixes
2026-11-19 0:02 [PATCH net-next 0/2] ibmveth: two TX and reset fixes Mingming Cao
2026-11-19 0:02 ` [PATCH net-next 1/2] ibmveth: drop TX on a queue whose long term buffer was freed Mingming Cao
2026-11-19 0:02 ` [PATCH net-next 2/2] ibmveth: do not reopen a device that was set down before reset ran Mingming Cao
@ 2026-11-19 0:07 ` netdev-bot+sinfo
2026-11-19 0:29 ` mingming cao
2 siblings, 1 reply; 6+ messages in thread
From: netdev-bot+sinfo @ 2026-11-19 0:07 UTC (permalink / raw)
To: Mingming Cao
Cc: netdev, nnac123, maddy, mpe, npiggin, chleroy, ritesh.list,
sshegde, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/2] ibmveth: two TX and reset fixes
2026-11-19 0:07 ` [PATCH net-next 0/2] ibmveth: two TX and reset fixes netdev-bot+sinfo
@ 2026-11-19 0:29 ` mingming cao
0 siblings, 0 replies; 6+ messages in thread
From: mingming cao @ 2026-11-19 0:29 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: netdev, nnac123, maddy, mpe, npiggin, chleroy, ritesh.list,
sshegde, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
On 11/18/26 4:07 PM, netdev-bot+sinfo@kernel.org wrote:
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
Thanks.
Some of this context was included in the cover letter, but for reviewers'
convenience:
Both issues were identified during development and review of the ibmveth
multi-queue work. Patch 1 addresses a race when TX queues are reduced via
ethtool -L while traffic is running. Patch 2 addresses a race where a queued
reset can reopen a device that has already been administratively brought
down.
I could not reproduce either issue directly. The fixes are based on
analysis of
the existing code paths and rare race conditions. I exercised the affected
scenarios on a PowerVM LPAR, including TX queue reduction under traffic,
ifdown/up during iperf3 traffic, and queued reset testing while the
device was
being brought down, and observed no regressions with the proposed fixes.
Thanks,
Mingming
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] ibmveth: drop TX on a queue whose long term buffer was freed
2026-11-19 0:02 ` [PATCH net-next 1/2] ibmveth: drop TX on a queue whose long term buffer was freed Mingming Cao
@ 2026-11-23 0:44 ` netdev-bot+sashiko
0 siblings, 0 replies; 6+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 0:44 UTC (permalink / raw)
To: mmc
Cc: netdev, nnac123, maddy, mpe, npiggin, chleroy, ritesh.list,
sshegde, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The new NULL check in ibmveth_start_xmit()
(drivers/net/ethernet/ibm/ibmveth.c:1312) depends on the sender seeing…
- [Low] The patch treats adapter->tx_ltb_ptr[] as lockless-read state.
--
ibmveth: drop TX on a queue whose long term buffer was freed
This patch makes ibmveth_start_xmit() read the TX long term buffer
pointer once with READ_ONCE() and drop the packet if it is NULL. The NULL
store in ibmveth_free_tx_ltb() is annotated with WRITE_ONCE(), and
ibmveth_set_channels() switches from netif_tx_stop_all_queues() to
netif_tx_disable() so in-flight senders leave before LTBs are changed.
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index 05d6b60cd187d..faacff14841b4 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
> @@ -599,7 +599,7 @@ static void ibmveth_free_tx_ltb(struct ibmveth_adapter *adapter, int idx)
> if (!ptr)
> return;
>
> - adapter->tx_ltb_ptr[idx] = NULL;
> + WRITE_ONCE(adapter->tx_ltb_ptr[idx], NULL);
> dma_unmap_single(&adapter->vdev->dev, adapter->tx_ltb_dma[idx],
> adapter->tx_ltb_size, DMA_TO_DEVICE);
> kfree(ptr);
[Severity: Low]
This isn't a bug, but the lockless annotation here covers only one of the
two writers of tx_ltb_ptr[]. The other one, ibmveth_allocate_tx_ltb()
(called from ibmveth_open() and ibmveth_set_channels()), still publishes
the pointer with a plain store before the buffer is DMA mapped:
ibmveth_allocate_tx_ltb() {
adapter->tx_ltb_ptr[idx] = kzalloc(adapter->tx_ltb_size,
GFP_KERNEL);
...
adapter->tx_ltb_dma[idx] = dma_map_single(&adapter->vdev->dev,
...
if (dma_mapping_error(&adapter->vdev->dev, adapter->tx_ltb_dma[idx])) {
...
kfree(adapter->tx_ltb_ptr[idx]);
adapter->tx_ltb_ptr[idx] = NULL;
return -ENOMEM;
}
}
On a mapping error it frees the buffer while the published pointer is
still non-NULL. That is the reverse of the NULL, unmap, free order used in
ibmveth_free_tx_ltb().
Several other accesses are also plain: the first load in
ibmveth_free_tx_ltb() and the tx_ltb_ptr[] checks in
ibmveth_set_channels(). In addition, ibmveth_start_xmit() re-reads
tx_ltb_dma[queue_num] without taking a snapshot of it next to ltb.
The READ_ONCE()/WRITE_ONCE() pair and the new comment suggest a reader
can run concurrently. If so, could the allocate path expose an unmapped
or freed LTB?
If no reader can run concurrently, because the stopped txqs provide the
serialization, could the comment say that instead? Otherwise, the
allocate path could get the same treatment: map into a local, then
WRITE_ONCE() the pointer, and leave the published pointer NULL on error.
> @@ -1195,7 +1195,7 @@ static int ibmveth_set_channels(struct net_device *netdev,
> /* We have IBMVETH_MAX_QUEUES netdev_queue's allocated
> * but we may need to alloc/free the ltb's.
> */
> - netif_tx_stop_all_queues(netdev);
> + netif_tx_disable(netdev);
>
> /* Allocate any queue that we need */
> for (i = old; i < goal; i++) {
[ ... ]
> @@ -1304,6 +1304,16 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,
> union ibmveth_buf_desc desc;
> int i, queue_num = skb_get_queue_mapping(skb);
> unsigned long mss = 0;
> + void *ltb;
> +
> + /* A sender that picked its queue before ethtool -L shrank the TX
> + * queues can get here after that queue's LTB was freed.
> + */
> + ltb = READ_ONCE(adapter->tx_ltb_ptr[queue_num]);
> + if (unlikely(!ltb)) {
> + netdev->stats.tx_dropped++;
> + goto out;
> + }
[Severity: Medium]
Is this NULL check ordered against the queue wake in
ibmveth_set_channels()?
netif_tx_disable() takes and releases each txq lock while it sets
DRV_XOFF. The LTB updates and the wake come after that, with no txq lock
held:
ibmveth_set_channels()
netif_tx_disable(netdev); <- all txq locks dropped here
...
ibmveth_free_tx_ltb(adapter, i - 1);
WRITE_ONCE(adapter->tx_ltb_ptr[idx], NULL);
dma_unmap_single(...);
kfree(ptr);
netif_tx_wake_all_queues(netdev); <- test_and_clear_bit on every queue,
including the removed ones
A sender still using a removed queue, such as AF_PACKET with
PACKET_QDISC_BYPASS, goes through:
__dev_direct_xmit()
HARD_TX_LOCK(dev, txq, smp_processor_id());
if (!netif_xmit_frozen_or_drv_stopped(txq)) <- plain load of txq->state
netdev_start_xmit()
ibmveth_start_xmit()
ltb = READ_ONCE(adapter->tx_ltb_ptr[queue_num]);
The writer's last txq unlock comes before the NULL store, so the lock
does not order that store against the sender. The only link between the
two sides is the fully ordered test_and_clear_bit(). On the reader side,
its two loads are separated only by a control dependency. That is the
MP+fence+ctrl pattern, and both LKMM and Power allow it.
Could a sender then see the queue as awake, still load the old kfree'd
LTB pointer, and memcpy() packet data into freed memory? The window is
very narrow, but nothing here seems to rule it out.
The grow path has a similar gap. ibmveth_allocate_tx_ltb() stores
tx_ltb_ptr[i] and then tx_ltb_dma[i], and ibmveth_start_xmit() re-reads
the DMA address later with no ordering:
desc.fields.address = adapter->tx_ltb_dma[queue_num];
ibmveth_free_tx_ltb() never clears tx_ltb_dma[]. Can a sender pair a new
non-NULL ltb with a stale tx_ltb_dma[] value and post a descriptor with an
unmapped or old IOVA? The commit message says this case is handled:
On a grow, that sender could otherwise see a new LTB before it is DMA
mapped, or one that the failure path frees again.
Would any of these close the gap?
- Call netif_tx_lock_bh()/netif_tx_unlock_bh() after the LTB updates and
before waking the queues.
- Update the pointers while holding each txq lock.
- Do not wake queues >= real_num_tx_queues.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119000235.15622-1-mmc%40linux.ibm.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-23 0:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 0:02 [PATCH net-next 0/2] ibmveth: two TX and reset fixes Mingming Cao
2026-11-19 0:02 ` [PATCH net-next 1/2] ibmveth: drop TX on a queue whose long term buffer was freed Mingming Cao
2026-11-23 0:44 ` netdev-bot+sashiko
2026-11-19 0:02 ` [PATCH net-next 2/2] ibmveth: do not reopen a device that was set down before reset ran Mingming Cao
2026-11-19 0:07 ` [PATCH net-next 0/2] ibmveth: two TX and reset fixes netdev-bot+sinfo
2026-11-19 0:29 ` mingming cao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox