]> git.hungrycats.org Git - linux/commit
xfrm: validate selector family and prefixlen during match
authorEric Dumazet <edumazet@google.com>
Mon, 15 Jun 2026 09:02:37 +0000 (09:02 +0000)
committerSteffen Klassert <steffen.klassert@secunet.com>
Wed, 17 Jun 2026 09:17:27 +0000 (11:17 +0200)
commit40f0b1047918539f0b0f795ac65e35336b4c2c78
tree8dbde7b36c13db4e1ffc69ff553cab1cac9a6716
parent007800408002d871f5699bdb944f985896730b8f
xfrm: validate selector family and prefixlen during match

syzbot reported a shift-out-of-bounds in xfrm_selector_match()
due to AF_UNSPEC selector with large prefixlen (e.g. 128) matched
against IPv4 flow (when XFRM_STATE_AF_UNSPEC is set).

Fix this by:

- Rejecting mismatched families in xfrm_selector_match.
- Returning false in addr4_match if prefixlen > 32.
- Returning false in addr_match if prefixlen > 128 (prevents overflow).

Fixes: 3f0ab59e6537 ("xfrm: validate new SA's prefixlen using SA family when sel.family is unset")
Reported-by: syzbot+9383b1ff0df4b29ca5e6@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/6a2fbe35.be3f099c.2836ae.0018.GAE@google.com/T/#u
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/net/xfrm.h
net/xfrm/xfrm_policy.c