Message ID | 20220720080912.1183369-2-steffen.klassert@secunet.com (mailing list archive) |
---|---|
State | Accepted |
Commit | f85daf0e725358be78dfd208dea5fd665d8cb901 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [1/2] xfrm: xfrm_policy: fix a possible double xfrm_pols_put() in xfrm_bundle_lookup() | expand |
Hello: This series was applied to netdev/net.git (master) by Steffen Klassert <steffen.klassert@secunet.com>: On Wed, 20 Jul 2022 10:09:11 +0200 you wrote: > From: Hangyu Hua <hbh25y@gmail.com> > > xfrm_policy_lookup() will call xfrm_pol_hold_rcu() to get a refcount of > pols[0]. This refcount can be dropped in xfrm_expand_policies() when > xfrm_expand_policies() return error. pols[0]'s refcount is balanced in > here. But xfrm_bundle_lookup() will also call xfrm_pols_put() with > num_pols == 1 to drop this refcount when xfrm_expand_policies() return > error. > > [...] Here is the summary with links: - [1/2] xfrm: xfrm_policy: fix a possible double xfrm_pols_put() in xfrm_bundle_lookup() https://git.kernel.org/netdev/net/c/f85daf0e7253 - [2/2] net: ipv4: fix clang -Wformat warnings https://git.kernel.org/netdev/net/c/e79b9473e9b5 You are awesome, thank you!
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index f1876ea61fdc..f1a0bab920a5 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -2678,8 +2678,10 @@ static int xfrm_expand_policies(const struct flowi *fl, u16 family, *num_xfrms = 0; return 0; } - if (IS_ERR(pols[0])) + if (IS_ERR(pols[0])) { + *num_pols = 0; return PTR_ERR(pols[0]); + } *num_xfrms = pols[0]->xfrm_nr; @@ -2694,6 +2696,7 @@ static int xfrm_expand_policies(const struct flowi *fl, u16 family, if (pols[1]) { if (IS_ERR(pols[1])) { xfrm_pols_put(pols, *num_pols); + *num_pols = 0; return PTR_ERR(pols[1]); } (*num_pols)++;