Skip to content

Commit f8e4717

Browse files
committed
netfilter: ipset: add missing range check in bitmap_ip_uadt
jira VULN-46550 cve CVE-2024-53141 commit-author Jeongjun Park <[email protected]> commit 35f56c5 When tb[IPSET_ATTR_IP_TO] is not present but tb[IPSET_ATTR_CIDR] exists, the values of ip and ip_to are slightly swapped. Therefore, the range check for ip should be done later, but this part is missing and it seems that the vulnerability occurs. So we should add missing range checks and remove unnecessary range checks. Cc: <[email protected]> Reported-by: [email protected] Fixes: 72205fc ("netfilter: ipset: bitmap:ip set type support") Signed-off-by: Jeongjun Park <[email protected]> Acked-by: Jozsef Kadlecsik <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> (cherry picked from commit 35f56c5) Signed-off-by: Anmol Jain <[email protected]>
1 parent 8b82a66 commit f8e4717

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

net/netfilter/ipset/ip_set_bitmap_ip.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,8 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],
165165
ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
166166
if (ret)
167167
return ret;
168-
if (ip > ip_to) {
168+
if (ip > ip_to)
169169
swap(ip, ip_to);
170-
if (ip < map->first_ip)
171-
return -IPSET_ERR_BITMAP_RANGE;
172-
}
173170
} else if (tb[IPSET_ATTR_CIDR]) {
174171
u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
175172

@@ -180,7 +177,7 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],
180177
ip_to = ip;
181178
}
182179

183-
if (ip_to > map->last_ip)
180+
if (ip < map->first_ip || ip_to > map->last_ip)
184181
return -IPSET_ERR_BITMAP_RANGE;
185182

186183
for (; !before(ip_to, ip); ip += map->hosts) {

0 commit comments

Comments
 (0)