Commit f85daf0
xfrm: xfrm_policy: fix a possible double xfrm_pols_put() in xfrm_bundle_lookup()
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.
This patch also fix an illegal address access. pols[0] will save a error
point when xfrm_policy_lookup fails. This lead to xfrm_pols_put to resolve
an illegal address in xfrm_bundle_lookup's error path.
Fix these by setting num_pols = 0 in xfrm_expand_policies()'s error path.
Fixes: 80c802f ("xfrm: cache bundles instead of policies for outgoing flows")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>1 parent 9f4fc18 commit f85daf0
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2678 | 2678 | | |
2679 | 2679 | | |
2680 | 2680 | | |
2681 | | - | |
| 2681 | + | |
| 2682 | + | |
2682 | 2683 | | |
| 2684 | + | |
2683 | 2685 | | |
2684 | 2686 | | |
2685 | 2687 | | |
| |||
2694 | 2696 | | |
2695 | 2697 | | |
2696 | 2698 | | |
| 2699 | + | |
2697 | 2700 | | |
2698 | 2701 | | |
2699 | 2702 | | |
| |||
0 commit comments