CVE-2021-47546

Severity CVSS v4.0:
Pending analysis
Type:
Unavailable / Other
Publication date:
24/05/2024
Last modified:
10/06/2024

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> ipv6: fix memory leak in fib6_rule_suppress<br /> <br /> The kernel leaks memory when a `fib` rule is present in IPv6 nftables<br /> firewall rules and a suppress_prefix rule is present in the IPv6 routing<br /> rules (used by certain tools such as wg-quick). In such scenarios, every<br /> incoming packet will leak an allocation in `ip6_dst_cache` slab cache.<br /> <br /> After some hours of `bpftrace`-ing and source code reading, I tracked<br /> down the issue to ca7a03c41753 ("ipv6: do not free rt if<br /> FIB_LOOKUP_NOREF is set on suppress rule").<br /> <br /> The problem with that change is that the generic `args-&gt;flags` always have<br /> `FIB_LOOKUP_NOREF` set[1][2] but the IPv6-specific flag<br /> `RT6_LOOKUP_F_DST_NOREF` might not be, leading to `fib6_rule_suppress` not<br /> decreasing the refcount when needed.<br /> <br /> How to reproduce:<br /> - Add the following nftables rule to a prerouting chain:<br /> meta nfproto ipv6 fib saddr . mark . iif oif missing drop<br /> This can be done with:<br /> sudo nft create table inet test<br /> sudo nft create chain inet test test_chain &amp;#39;{ type filter hook prerouting priority filter + 10; policy accept; }&amp;#39;<br /> sudo nft add rule inet test test_chain meta nfproto ipv6 fib saddr . mark . iif oif missing drop<br /> - Run:<br /> sudo ip -6 rule add table main suppress_prefixlength 0<br /> - Watch `sudo slabtop -o | grep ip6_dst_cache` to see memory usage increase<br /> with every incoming ipv6 packet.<br /> <br /> This patch exposes the protocol-specific flags to the protocol<br /> specific `suppress` function, and check the protocol-specific `flags`<br /> argument for RT6_LOOKUP_F_DST_NOREF instead of the generic<br /> FIB_LOOKUP_NOREF when decreasing the refcount, like this.<br /> <br /> [1]: https://github.com/torvalds/linux/blob/ca7a03c4175366a92cee0ccc4fec0038c3266e26/net/ipv6/fib6_rules.c#L71<br /> [2]: https://github.com/torvalds/linux/blob/ca7a03c4175366a92cee0ccc4fec0038c3266e26/net/ipv6/fib6_rules.c#L99

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.4 (including) 5.4.164 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.5 (including) 5.10.84 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.11 (including) 5.15.7 (excluding)