public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: "Leon Romanovsky <leon@kernel.org> Leon Romanovsky
	<leonro@nvidia.com> Shannon Nelson <shannon.nelson@oracle.com>
	Steffen Klassert <steffen.klassert@secunet.com> Yossef Efraim"
	<yossefe@mellanox.com>,
	Network Development <netdev@vger.kernel.org>
Subject: Re: xfrm: Possible refcount bug in xfrm_dev_state_add() ?
Date: Sun, 18 Jan 2026 19:08:03 +0200	[thread overview]
Message-ID: <20260118170803.GC13201@unreal> (raw)
In-Reply-To: <c232db28-622d-4dd9-a61f-f12cd0ff39bb@I-love.SAKURA.ne.jp>

On Sat, Jan 17, 2026 at 08:00:16PM +0900, Tetsuo Handa wrote:
> Just browsing call trace for
> 
>   unregister_netdevice: waiting for netdevsim0 to become free. Usage count = 2
>   ref_tracker: netdev@ffff888052f24618 has 1/1 users at
>        __netdev_tracker_alloc include/linux/netdevice.h:4400 [inline]
>        netdev_tracker_alloc include/linux/netdevice.h:4412 [inline]
>        xfrm_dev_state_add+0x3a5/0x1080 net/xfrm/xfrm_device.c:316
>        xfrm_state_construct net/xfrm/xfrm_user.c:986 [inline]
>        xfrm_add_sa+0x34ff/0x5fa0 net/xfrm/xfrm_user.c:1022
>        xfrm_user_rcv_msg+0x58e/0xc00 net/xfrm/xfrm_user.c:3507
>        netlink_rcv_skb+0x158/0x420 net/netlink/af_netlink.c:2550
>        xfrm_netlink_rcv+0x71/0x90 net/xfrm/xfrm_user.c:3529
>        netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
>        netlink_unicast+0x5aa/0x870 net/netlink/af_netlink.c:1344
>        netlink_sendmsg+0x8c8/0xdd0 net/netlink/af_netlink.c:1894
>        sock_sendmsg_nosec net/socket.c:727 [inline]
>        __sock_sendmsg net/socket.c:742 [inline]
>        ____sys_sendmsg+0xa5d/0xc30 net/socket.c:2592
>        ___sys_sendmsg+0x134/0x1d0 net/socket.c:2646
>        __sys_sendmsg+0x16d/0x220 net/socket.c:2678
>        do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
>        do_syscall_64+0xcd/0xf80 arch/x86/entry/syscall_64.c:94
>        entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> problem, I noticed a different-but-possible refcount bug.
> 
> Commit 67a63387b141 ("xfrm: Fix negative device refcount on offload failure.")
> resets xso->dev to NULL. Commit 50bd870a9e5c ("xfrm: Add ESN support for IPSec
> HW offload") also resets xso->dev to NULL. Then, why not commit 585b64f5a620
> ("xfrm: delay initialization of offload path till its actually requested") also
> resets xso->dev to NULL (like shown below) ? (Note that I don't know the
> background of these commits...)
> 
> diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
> index 52ae0e034d29..daa640f1ff9c 100644
> --- a/net/xfrm/xfrm_device.c
> +++ b/net/xfrm/xfrm_device.c
> @@ -308,6 +308,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
>  
>  	if (!x->type_offload) {
>  		NL_SET_ERR_MSG(extack, "Type doesn't support offload");
> +		xso->dev = NULL;

I do not expect this change to have any visible impact. After this failure,
the xso object should not be reused, so setting "xso->dev = NULL" is likely
unnecessary as well.

Thanks

>  		dev_put(dev);
>  		return -EINVAL;
>  	}
> 

      reply	other threads:[~2026-01-18 17:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-17 11:00 xfrm: Possible refcount bug in xfrm_dev_state_add() ? Tetsuo Handa
2026-01-18 17:08 ` Leon Romanovsky [this message]

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=20260118170803.GC13201@unreal \
    --to=leon@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=yossefe@mellanox.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