aboutsummaryrefslogtreecommitdiff
path: root/pkgs/patches-linux-5.15/612-netfilter_match_reduce_memory_access.patch
blob: 79da6778b684a56094bcddd334daa9660181d946 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
From: Felix Fietkau <nbd@nbd.name>
Subject: netfilter: reduce match memory access

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 net/ipv4/netfilter/ip_tables.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -53,9 +53,9 @@ ip_packet_match(const struct iphdr *ip,
 	if (ipinfo->flags & IPT_F_NO_DEF_MATCH)
 		return true;
 
-	if (NF_INVF(ipinfo, IPT_INV_SRCIP,
+	if (NF_INVF(ipinfo, IPT_INV_SRCIP, ipinfo->smsk.s_addr &&
 		    (ip->saddr & ipinfo->smsk.s_addr) != ipinfo->src.s_addr) ||
-	    NF_INVF(ipinfo, IPT_INV_DSTIP,
+	    NF_INVF(ipinfo, IPT_INV_DSTIP, ipinfo->dmsk.s_addr &&
 		    (ip->daddr & ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr))
 		return false;