Skip to content

Commit 47d6528

Browse files
committed
netfilter: ipset: add missing range check in bitmap_ip_uadt
jira VULN-46558 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 768b658 commit 47d6528

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
@@ -163,11 +163,8 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],
163163
ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
164164
if (ret)
165165
return ret;
166-
if (ip > ip_to) {
166+
if (ip > ip_to)
167167
swap(ip, ip_to);
168-
if (ip < map->first_ip)
169-
return -IPSET_ERR_BITMAP_RANGE;
170-
}
171168
} else if (tb[IPSET_ATTR_CIDR]) {
172169
u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
173170

@@ -178,7 +175,7 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],
178175
ip_to = ip;
179176
}
180177

181-
if (ip_to > map->last_ip)
178+
if (ip < map->first_ip || ip_to > map->last_ip)
182179
return -IPSET_ERR_BITMAP_RANGE;
183180

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

0 commit comments

Comments
 (0)