mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-10-26 10:57:38 +08:00
netfilter: ctnetlink: fix inverted IPv6 address match in dump filter
ctnetlink_filter_match_tuple() rejects an entry when
!ipv6_addr_cmp(filter, entry) is true. ipv6_addr_cmp() is a memcmp() and
returns 0 for equal addresses, so the condition is true exactly when the
addresses match: a CTA_FILTER dump with an IPv6 CTA_IP_SRC or CTA_IP_DST
skips every entry that matches the requested address and returns all the
others. The IPv4 branch compares with != and behaves correctly.
Observed with libnetfilter_conntrack NFCT_FILTER_DUMP_TUPLE: a dump
filtered on src 2001:db8::10 returned only the unrelated entries, and a
dump filtered on ::1 returned every entry except the ::1 ones.
conntrack-tools does not use the tuple filter for -L, which is why this
went unnoticed.
Use ipv6_addr_equal() so the IPv6 branch mirrors the IPv4 one.
Fixes: cb8aa9a3af ("netfilter: ctnetlink: add kernel side filtering for dump")
Cc: stable@vger.kernel.org
Signed-off-by: Piotr Kubik <piotr@kubik.pl>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
1 parent
d3950004ba
commit
1ae2d094b0
1 file changed
+4
-4
@@ -1098,13 +1098,13 @@ static int ctnetlink_filter_match_tuple(struct nf_conntrack_tuple *filter_tuple,
|
||||
break;
|
||||
case NFPROTO_IPV6:
|
||||
if ((flags & CTA_FILTER_FLAG(CTA_IP_SRC)) &&
|
||||
!ipv6_addr_cmp(&filter_tuple->src.u3.in6,
|
||||
&ct_tuple->src.u3.in6))
|
||||
!ipv6_addr_equal(&filter_tuple->src.u3.in6,
|
||||
&ct_tuple->src.u3.in6))
|
||||
return 0;
|
||||
|
||||
if ((flags & CTA_FILTER_FLAG(CTA_IP_DST)) &&
|
||||
!ipv6_addr_cmp(&filter_tuple->dst.u3.in6,
|
||||
&ct_tuple->dst.u3.in6))
|
||||
!ipv6_addr_equal(&filter_tuple->dst.u3.in6,
|
||||
&ct_tuple->dst.u3.in6))
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user