xfrm: Check if_id in inbound policy/secpath match
authorBenedict Wong <benedictwong@google.com>
Wed, 10 May 2023 01:14:14 +0000 (01:14 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Jun 2023 08:34:10 +0000 (10:34 +0200)
commitf6d2aa322ca78af88d210d0de7ca09d35bc60626
tree2c1227d0dbeb1ffcb96c4a52dc384d39a3379033
parent40798c566b567621ab98b3c2a779df8bd6d98aa7
xfrm: Check if_id in inbound policy/secpath match

[ Upstream commit 8680407b6f8f5fba59e8f1d63c869abc280f04df ]

This change ensures that if configured in the policy, the if_id set in
the policy and secpath states match during the inbound policy check.
Without this, there is potential for ambiguity where entries in the
secpath differing by only the if_id could be mismatched.

Notably, this is checked in the outbound direction when resolving
templates to SAs, but not on the inbound path when matching SAs and
policies.

Test: Tested against Android kernel unit tests & CTS
Signed-off-by: Benedict Wong <benedictwong@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/xfrm/xfrm_policy.c