* xfrm: Possible refcount bug in xfrm_dev_state_add() ?
@ 2026-01-17 11:00 Tetsuo Handa
2026-01-18 17:08 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Tetsuo Handa @ 2026-01-17 11:00 UTC (permalink / raw)
To: Leon Romanovsky <leon@kernel.org> Leon Romanovsky <leonro@nvidia.com> Shannon Nelson <shannon.nelson@oracle.com> Steffen Klassert <steffen.klassert@secunet.com> Yossef Efraim
Cc: Network Development
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;
dev_put(dev);
return -EINVAL;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: xfrm: Possible refcount bug in xfrm_dev_state_add() ?
2026-01-17 11:00 xfrm: Possible refcount bug in xfrm_dev_state_add() ? Tetsuo Handa
@ 2026-01-18 17:08 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-01-18 17:08 UTC (permalink / raw)
To: Tetsuo Handa
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,
Network Development
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;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-18 17:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-17 11:00 xfrm: Possible refcount bug in xfrm_dev_state_add() ? Tetsuo Handa
2026-01-18 17:08 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox