]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
xfrm: fix xfrm child route lookup for packet offload
authorMike Yu <yumike@google.com>
Mon, 4 Mar 2024 12:24:08 +0000 (12:24 +0000)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:15 +0000 (18:19 -0400)
commit4f77a8c2137355a8b63b7d44a7452045b7c7a98b
tree0c6931a87614fb482e88f228dfb9c7e403bf5977
parent5171cac6f5c3fff923dd08625c41b29737be4163
xfrm: fix xfrm child route lookup for packet offload

[ Upstream commit d4872d70fc6feabfc8e897edad993a81096ade9f ]

In current code, xfrm_bundle_create() always uses the matched
SA's family type to look up a xfrm child route for the skb.
The route returned by xfrm_dst_lookup() will eventually be
used in xfrm_output_resume() (skb_dst(skb)->ops->local_out()).

If packet offload is used, the above behavior can lead to
calling ip_local_out() for an IPv6 packet or calling
ip6_local_out() for an IPv4 packet, which is likely to fail.

This change fixes the behavior by checking if the matched SA
has packet offload enabled. If not, keep the same behavior;
if yes, use the matched SP's family type for the lookup.

Test: verified IPv6-in-IPv4 packets on Android device with
      IPsec packet offload enabled
Signed-off-by: Mike Yu <yumike@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/xfrm/xfrm_policy.c