Netdev List
 help / color / mirror / Atom feed
From: mingming cao <mmc@linux.ibm.com>
To: netdev-bot+sashiko@kernel.org
Cc: netdev@vger.kernel.org, nnac123@linux.ibm.com,
	maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
	chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com,
	linuxppc-dev@lists.ozlabs.org, horms@kernel.org,
	davemarq@linux.ibm.com, haren@linux.ibm.com,
	ricklind@linux.ibm.com, bjking1@linux.ibm.com,
	shaik.abdulla1@ibm.com
Subject: Re: [PATCH net-next 1/2] ibmveth: drop TX on a queue whose long term buffer was freed
Date: Sun, 22 Nov 2026 23:31:33 -0800	[thread overview]
Message-ID: <45443018-951c-452c-a3e4-383b7b9a9cb4@linux.ibm.com> (raw)
In-Reply-To: <179539467281.3135.6706630717389291385@kernel.org>


On 11/22/26 4:44 PM, netdev-bot+sashiko@kernel.org wrote:
> 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.
>
> --
...
> [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.
>
> [ ... ]
I'll send version 2. it wakes the queues under netif_tx_lock_bh(), and only
publishes a new LTB pointer after it is mapped.

pw-bot: cr

Thanks,
Mingming

  reply	other threads:[~2026-11-23  7:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-23  7:31     ` mingming cao [this message]
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

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=45443018-951c-452c-a3e4-383b7b9a9cb4@linux.ibm.com \
    --to=mmc@linux.ibm.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjking1@linux.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=davem@davemloft.net \
    --cc=davemarq@linux.ibm.com \
    --cc=edumazet@kernel.org \
    --cc=haren@linux.ibm.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nnac123@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=ricklind@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=shaik.abdulla1@ibm.com \
    --cc=sshegde@linux.ibm.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