* [Patch net] xfrm: check id proto in validate_tmpl()
@ 2017-11-27 19:15 Cong Wang
2017-11-29 12:15 ` Steffen Klassert
0 siblings, 1 reply; 2+ messages in thread
From: Cong Wang @ 2017-11-27 19:15 UTC (permalink / raw)
To: netdev; +Cc: Cong Wang, Steffen Klassert, Herbert Xu
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>
---
net/xfrm/xfrm_user.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 983b0233767b..c2cfcc6fdb34 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1445,6 +1445,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;
--
2.13.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch net] xfrm: check id proto in validate_tmpl()
2017-11-27 19:15 [Patch net] xfrm: check id proto in validate_tmpl() Cong Wang
@ 2017-11-29 12:15 ` Steffen Klassert
0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2017-11-29 12:15 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, Herbert Xu
On Mon, Nov 27, 2017 at 11:15:16AM -0800, Cong Wang wrote:
> 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>
Patch applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-29 12:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-27 19:15 [Patch net] xfrm: check id proto in validate_tmpl() Cong Wang
2017-11-29 12:15 ` Steffen Klassert
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.