diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2017-11-10 06:14:06 +0300 |
---|---|---|
committer | Sasha Levin <alexander.levin@microsoft.com> | 2018-01-17 20:55:29 +0300 |
commit | b486022b7bb8ccce0e44d43e77f15ed5f9f6cb68 (patch) | |
tree | 467b82d1174c1a3d3a4f1cf7c98aa215f8580511 | |
parent | 0770152f94381de6750af9bc809f8a5f81e4909a (diff) | |
download | linux-b486022b7bb8ccce0e44d43e77f15ed5f9f6cb68.tar.xz |
xfrm: Copy policy family in clone_policy
[ Upstream commit 0e74aa1d79a5bbc663e03a2804399cae418a0321 ]
The syzbot found an ancient bug in the IPsec code. When we cloned
a socket policy (for example, for a child TCP socket derived from a
listening socket), we did not copy the family field. This results
in a live policy with a zero family field. This triggers a BUG_ON
check in the af_key code when the cloned policy is retrieved.
This patch fixes it by copying the family field over.
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
-rw-r--r-- | net/xfrm/xfrm_policy.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 85cddb37feac..7306683a7207 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -1352,6 +1352,7 @@ static struct xfrm_policy *clone_policy(const struct xfrm_policy *old, int dir) newp->xfrm_nr = old->xfrm_nr; newp->index = old->index; newp->type = old->type; + newp->family = old->family; memcpy(newp->xfrm_vec, old->xfrm_vec, newp->xfrm_nr*sizeof(struct xfrm_tmpl)); write_lock_bh(&net->xfrm.xfrm_policy_lock); |