OSDN Git Service

xfrm: Fix stack-out-of-bounds read on socket policy lookup.
authorSteffen Klassert <steffen.klassert@secunet.com>
Wed, 29 Nov 2017 05:53:55 +0000 (06:53 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Feb 2018 10:03:35 +0000 (11:03 +0100)
commit7800c76fb039e3d88cbdae49e3e1a47098e71111
treecb587b2656c65da591d91de293abde1441ac5f79
parent0de023ab7d3e907d1e9174e04ec44b80fac14de5
xfrm: Fix stack-out-of-bounds read on socket policy lookup.

commit ddc47e4404b58f03e98345398fb12d38fe291512 upstream.

When we do tunnel or beet mode, we pass saddr and daddr from the
template to xfrm_state_find(), this is ok. On transport mode,
we pass the addresses from the flowi, assuming that the IP
addresses (and address family) don't change during transformation.
This assumption is wrong in the IPv4 mapped IPv6 case, packet
is IPv4 and template is IPv6.

Fix this by catching address family missmatches of the policy
and the flow already before we do the lookup.

Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/xfrm/xfrm_policy.c