Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mmc@linux.ibm.com
Cc: netdev@vger.kernel.org, maddy@linux.ibm.com, mpe@ellerman.id.au,
	npiggin@gmail.com, chleroy@kernel.org, ritesh.list@gmail.com,
	sshegde@linux.ibm.com, nnac123@linux.ibm.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	horms@kernel.org, davemarq@linux.ibm.com, bjking1@linux.ibm.com,
	tlfalcon@linux.vnet.ibm.com, brking@linux.vnet.ibm.com,
	zdai@us.ibm.com, pradeeps@linux.vnet.ibm.com,
	ksiva@linux.vnet.ibm.com
Subject: Re: [PATCH net-next v5 5/9] ibmveth: release the pool kobjects when probe fails
Date: Sat, 17 Oct 2026 19:08:14 +0000	[thread overview]
Message-ID: <179226409492.3135.9899803798328301877@kernel.org> (raw)
In-Reply-To: <20261013182926.30417-6-mmc@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

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).

- [High] kobject: module unload race causing execution-after-free

--

> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
> @@ -1890,6 +1890,40 @@ static const struct net_device_ops ibmveth_netdev_ops = {
>  	.ndo_features_check	= ibmveth_features_check,
>  };
>  
> +/**
> + * ibmveth_pool_kobj_release - Mark a pool kobject finished
> + * @kobj: kobject embedded in the pool
> + *
> + * The pool kobjects live in netdev_priv(), so the last put must wait
> + * for this before free_netdev().
> + */
> +static void ibmveth_pool_kobj_release(struct kobject *kobj)
> +{
> +	struct ibmveth_buff_pool *pool = container_of(kobj,
> +						      struct ibmveth_buff_pool,
> +						      kobj);
> +
> +	complete(&pool->released);
> +}
> +
> +/**
> + * ibmveth_put_pool_kobjs - Drop the pool kobjects and wait for release
> + * @adapter: ibmveth adapter
> + *
> + * With CONFIG_DEBUG_KOBJECT_RELEASE the cleanup, including removing the
> + * sysfs files, runs later from a work item in the kobject; wait for it
> + * so free_netdev() cannot free the pools first.
> + */
> +static void ibmveth_put_pool_kobjs(struct ibmveth_adapter *adapter)
> +{
> +	int i;
> +
> +	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
> +		kobject_put(&adapter->rx_buff_pool[i].kobj);
> +	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
> +		wait_for_completion(&adapter->rx_buff_pool[i].released);
> +}
> +
>  static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
>  {
>  	int rc, i, mac_len;

[Severity: High]
With CONFIG_DEBUG_KOBJECT_RELEASE, ibmveth_pool_kobj_release() runs
from the kobject's delayed release work, not from kobject_put(). The
complete(&pool->released) here wakes ibmveth_put_pool_kobjs() in
ibmveth_remove(). Remove can then return and let
vio_unregister_driver() and the module unload finish while the worker
is still inside ibmveth_pool_kobj_release(), on its way back from
complete(). That CPU then executes freed module text. So rmmod can
oops in exactly the configuration this v2 was meant to make safe.

Signalling a completion from module code does not by itself prove the
signaller has left the module; that is why kthread_complete_and_exit()
exists.

Waiting in remove() for the final put is also not how kobject lifetime
is meant to work. release() should free the containing object rather
than hand it back to someone blocked on it.

Would it be simpler to drop the separate pool kobjects and create the
pool%d directories as named attribute groups on dev->dev.kobj? Then
nothing with its own refcount lives in netdev_priv(). The trade-off is
that veth_pool_show() and veth_pool_store() would need another way to
find the pool than container_of() on the kobject. How do you want to
handle this?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261013182926.30417-1-mmc%40linux.ibm.com

  reply	other threads:[~2026-10-17 19:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 18:29 [PATCH net-next v5 0/9] ibmveth: fix hangs, use-after-frees and netpoll races Mingming Cao
2026-10-13 18:29 ` [PATCH net-next v5 1/9] ibmveth: fix netpoll races with RX replenish Mingming Cao
2026-10-17 19:08   ` netdev-bot+sashiko
2026-10-13 18:29 ` [PATCH net-next v5 2/9] ibmveth: do not close twice after a failed reopen Mingming Cao
2026-10-13 18:29 ` [PATCH net-next v5 3/9] ibmveth: disable the reset work before unregister in remove Mingming Cao
2026-10-13 18:29 ` [PATCH net-next v5 4/9] ibmveth: step past bad RX correlators instead of spinning or oopsing Mingming Cao
2026-10-13 18:29 ` [PATCH net-next v5 5/9] ibmveth: release the pool kobjects when probe fails Mingming Cao
2026-10-17 19:08   ` netdev-bot+sashiko [this message]
2026-10-13 18:29 ` [PATCH net-next v5 6/9] ibmveth: return the error when set_channels cannot add TX queues Mingming Cao
2026-10-13 18:29 ` [PATCH net-next v5 7/9] ibmveth: wait for in-flight transmits in ibmveth_close() Mingming Cao
2026-10-13 18:29 ` [PATCH net-next v5 8/9] ibmveth: wait for the RX poll to return before freeing the RX queue Mingming Cao
2026-10-13 18:29 ` [PATCH net-next v5 9/9] ibmveth: check headers in the RX large send and checksum helpers Mingming Cao
2026-10-17 19:08   ` netdev-bot+sashiko

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=179226409492.3135.9899803798328301877@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjking1@linux.ibm.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=davem@davemloft.net \
    --cc=davemarq@linux.ibm.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=ksiva@linux.vnet.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mmc@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=netdev@vger.kernel.org \
    --cc=nnac123@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=pradeeps@linux.vnet.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=sshegde@linux.ibm.com \
    --cc=tlfalcon@linux.vnet.ibm.com \
    --cc=zdai@us.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