linux/net/xfrm
Paul Chaignon 0b91fda3a1 xfrm: Sanitize marks before insert
Prior to this patch, the mark is sanitized (applying the state's mask to
the state's value) only on inserts when checking if a conflicting XFRM
state or policy exists.

We discovered in Cilium that this same sanitization does not occur
in the hot-path __xfrm_state_lookup. In the hot-path, the sk_buff's mark
is simply compared to the state's value:

    if ((mark & x->mark.m) != x->mark.v)
        continue;

Therefore, users can define unsanitized marks (ex. 0xf42/0xf00) which will
never match any packet.

This commit updates __xfrm_state_insert and xfrm_policy_insert to store
the sanitized marks, thus removing this footgun.

This has the side effect of changing the ip output, as the
returned mark will have the mask applied to it when printed.

Fixes: 3d6acfa764 ("xfrm: SA lookups with mark")
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Signed-off-by: Louis DeLosSantos <louis.delos.devel@gmail.com>
Co-developed-by: Louis DeLosSantos <louis.delos.devel@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
2025-05-14 07:18:58 +02:00
..
espintcp.c espintcp: fix skb leaks 2025-04-14 11:58:50 +02:00
Kconfig xfrm: config: add CONFIG_XFRM_IPTFS 2024-12-05 10:00:53 +01:00
Makefile xfrm: iptfs: add new iptfs xfrm mode impl 2024-12-05 10:01:35 +01:00
trace_iptfs.h xfrm: iptfs: add tracepoint functionality 2024-12-05 10:02:36 +01:00
xfrm_algo.c xfrm: ipcomp: Use crypto_acomp interface 2025-03-21 17:36:49 +08:00
xfrm_compat.c xfrm: netlink: add config (netlink) options 2024-12-05 10:01:15 +01:00
xfrm_device.c xfrm: check for PMTU in tunnel mode for packet offload 2025-02-21 08:08:15 +01:00
xfrm_hash.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
xfrm_hash.h xfrm: add state hashtable keyed by seq 2021-05-14 13:52:01 +02:00
xfrm_inout.h xfrm: move xfrm4_extract_header to common helper 2020-05-06 09:40:08 +02:00
xfrm_input.c net: remove init_dummy_netdev() 2025-01-13 19:06:51 -08:00
xfrm_interface_bpf.c bpf: treewide: Annotate BPF kfuncs in BTF 2024-01-31 20:40:56 -08:00
xfrm_interface_core.c net: xfrm: Use link netns in newlink() of rtnl_link_ops 2025-02-21 15:28:03 -08:00
xfrm_ipcomp.c xfrm: ipcomp: fix truesize computation on receive 2025-04-30 08:08:16 +02:00
xfrm_iptfs.c xfrm: Switch to use hrtimer_setup() 2025-02-18 10:35:47 +01:00
xfrm_nat_keepalive.c xfrm: support sending NAT keepalives in ESP in UDP states 2024-06-26 13:22:42 +02:00
xfrm_output.c ipsec-next-2025-03-24 2025-03-25 08:50:10 -07:00
xfrm_policy.c xfrm: Sanitize marks before insert 2025-05-14 07:18:58 +02:00
xfrm_proc.c xfrm: add generic iptfs defines and functionality 2024-12-05 10:01:28 +01:00
xfrm_replay.c ipsec-2025-01-27 2025-01-27 15:15:12 -08:00
xfrm_state_bpf.c bpf: treewide: Annotate BPF kfuncs in BTF 2024-01-31 20:40:56 -08:00
xfrm_state.c xfrm: Sanitize marks before insert 2025-05-14 07:18:58 +02:00
xfrm_sysctl.c net: Remove ctl_table sentinel elements from several networking subsystems 2024-05-03 13:29:42 +01:00
xfrm_user.c xfrm: simplify SA initialization routine 2025-02-21 08:08:15 +01:00