diff options
author | Benedict Wong <benedictwong@google.com> | 2023-01-05 22:28:12 +0100 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2023-01-09 07:11:05 +0100 |
commit | b0355dbbf13c0052931dd14c38c789efed64d3de (patch) | |
tree | 1dddb76fc46939172baea8b293efbd877e28f0f8 /net/xfrm/xfrm_policy.c | |
parent | Merge tag 'rxrpc-fixes-20230107' of git://git.kernel.org/pub/scm/linux/kernel... (diff) | |
download | linux-b0355dbbf13c0052931dd14c38c789efed64d3de.tar.xz linux-b0355dbbf13c0052931dd14c38c789efed64d3de.zip |
Fix XFRM-I support for nested ESP tunnels
This change adds support for nested IPsec tunnels by ensuring that
XFRM-I verifies existing policies before decapsulating a subsequent
policies. Addtionally, this clears the secpath entries after policies
are verified, ensuring that previous tunnels with no-longer-valid
do not pollute subsequent policy checks.
This is necessary especially for nested tunnels, as the IP addresses,
protocol and ports may all change, thus not matching the previous
policies. In order to ensure that packets match the relevant inbound
templates, the xfrm_policy_check should be done before handing off to
the inner XFRM protocol to decrypt and decapsulate.
Notably, raw ESP/AH packets did not perform policy checks inherently,
whereas all other encapsulated packets (UDP, TCP encapsulated) do policy
checks after calling xfrm_input handling in the respective encapsulation
layer.
Test: Verified with additional Android Kernel Unit tests
Signed-off-by: Benedict Wong <benedictwong@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm/xfrm_policy.c')
-rw-r--r-- | net/xfrm/xfrm_policy.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index e9eb82c5457d..ed0976f8e42b 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -3742,6 +3742,9 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, goto reject; } + if (if_id) + secpath_reset(skb); + xfrm_pols_put(pols, npols); return 1; } |