summaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2017-11-27 11:15:16 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-25 11:01:17 +0100
commita04a3d139ba8af2e8f5fd6c5f789e00ea3f4af34 (patch)
tree98f5f63c75bfb53638dfef4ef19d8cd7d8bbe0a8 /net/xfrm
parent2796fe7d00e46369bc766b79bd19e2394243e565 (diff)
downloadlinux-stable-a04a3d139ba8af2e8f5fd6c5f789e00ea3f4af34.tar.gz
linux-stable-a04a3d139ba8af2e8f5fd6c5f789e00ea3f4af34.tar.bz2
linux-stable-a04a3d139ba8af2e8f5fd6c5f789e00ea3f4af34.zip
xfrm: check id proto in validate_tmpl()
commit 6a53b7593233ab9e4f96873ebacc0f653a55c3e1 upstream. syzbot reported a kernel warning in xfrm_state_fini(), which indicates that we have entries left in the list net->xfrm.state_all whose proto is zero. And xfrm_id_proto_match() doesn't consider them as a match with IPSEC_PROTO_ANY in this case. Proto with value 0 is probably not a valid value, at least verify_newsa_info() doesn't consider it valid either. This patch fixes it by checking the proto value in validate_tmpl() and rejecting invalid ones, like what iproute2 does in xfrm_xfrmproto_getbyname(). Reported-by: syzbot <syzkaller@googlegroups.com> Cc: Steffen Klassert <steffen.klassert@secunet.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/xfrm_user.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 72d65b9978ca..76f6ff83aed0 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1375,6 +1375,21 @@ static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family)
default:
return -EINVAL;
}
+
+ switch (ut[i].id.proto) {
+ case IPPROTO_AH:
+ case IPPROTO_ESP:
+ case IPPROTO_COMP:
+#if IS_ENABLED(CONFIG_IPV6)
+ case IPPROTO_ROUTING:
+ case IPPROTO_DSTOPTS:
+#endif
+ case IPSEC_PROTO_ANY:
+ break;
+ default:
+ return -EINVAL;
+ }
+
}
return 0;