xfrm: Copy policy family in clone_policy
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 10 Nov 2017 03:14:06 +0000 (14:14 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Dec 2017 08:28:24 +0000 (09:28 +0100)
commit6ceabde6664331f096462ff8fcb6f79f303a78ce
tree99529ef1ee88afe96796d88bf68ad9c98a0c876b
parent74b470ce478a69bb3ce36b38e6c834d0578c3195
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@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/xfrm/xfrm_policy.c