Message ID | 20220824050213.3643599-2-steffen.klassert@secunet.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 9c9cb23e00ddf45679b21b4dacc11d1ae7961ebe |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [1/6] xfrm: fix refcount leak in __xfrm_policy_check() | expand |
Hello: This series was applied to netdev/net.git (master) by Steffen Klassert <steffen.klassert@secunet.com>: On Wed, 24 Aug 2022 07:02:08 +0200 you wrote: > From: Xin Xiong <xiongx18@fudan.edu.cn> > > The issue happens on an error path in __xfrm_policy_check(). When the > fetching process of the object `pols[1]` fails, the function simply > returns 0, forgetting to decrement the reference count of `pols[0]`, > which is incremented earlier by either xfrm_sk_policy_lookup() or > xfrm_policy_lookup(). This may result in memory leaks. > > [...] Here is the summary with links: - [1/6] xfrm: fix refcount leak in __xfrm_policy_check() https://git.kernel.org/netdev/net/c/9c9cb23e00dd - [2/6] Revert "xfrm: update SA curlft.use_time" https://git.kernel.org/netdev/net/c/717ada9f10f2 - [3/6] xfrm: fix XFRMA_LASTUSED comment https://git.kernel.org/netdev/net/c/36d763509be3 - [4/6] xfrm: clone missing x->lastused in xfrm_do_migrate https://git.kernel.org/netdev/net/c/6aa811acdb76 - [5/6] af_key: Do not call xfrm_probe_algs in parallel https://git.kernel.org/netdev/net/c/ba953a9d89a0 - [6/6] xfrm: policy: fix metadata dst->dev xmit null pointer dereference https://git.kernel.org/netdev/net/c/17ecd4a4db47 You are awesome, thank you!
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index f1a0bab920a5..4f8bbb825abc 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -3599,6 +3599,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, if (pols[1]) { if (IS_ERR(pols[1])) { XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR); + xfrm_pol_put(pols[0]); return 0; } pols[1]->curlft.use_time = ktime_get_real_seconds();