]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
xfrm: fix refcount leak in xfrm_migrate_policy_find
authorKotlyarov Mihail <mihailkotlyarow@gmail.com>
Sat, 4 Apr 2026 09:05:20 +0000 (12:05 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Apr 2026 11:30:40 +0000 (13:30 +0200)
commit70c2a89a3bc207c3bfbf6f21bb439809e0a4a27a
tree6b9aa8c78f80153b7b3c0873eff030b971bc8a51
parent33a3149dd81a1e2f52b80ee1e0fc380b39f3d028
xfrm: fix refcount leak in xfrm_migrate_policy_find

[ Upstream commit 83317cce60a032c49480dcdabe146435bd689d03 ]

syzkaller reported a memory leak in xfrm_policy_alloc:

  BUG: memory leak
  unreferenced object 0xffff888114d79000 (size 1024):
    comm "syz.1.17", pid 931
    ...
    xfrm_policy_alloc+0xb3/0x4b0 net/xfrm/xfrm_policy.c:432

The root cause is a double call to xfrm_pol_hold_rcu() in
xfrm_migrate_policy_find(). The lookup function already returns
a policy with held reference, making the second call redundant.

Remove the redundant xfrm_pol_hold_rcu() call to fix the refcount
imbalance and prevent the memory leak.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes: 563d5ca93e88 ("xfrm: switch migrate to xfrm_policy_lookup_bytype")
Signed-off-by: Kotlyarov Mihail <mihailkotlyarow@gmail.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/xfrm/xfrm_policy.c