Skip to content

Commit 4f61f98

Browse files
committed
netfilter: ipset: add missing range check in bitmap_ip_uadt
jira VULN-46554 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 692349b commit 4f61f98

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
@@ -166,11 +166,8 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],
166166
ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
167167
if (ret)
168168
return ret;
169-
if (ip > ip_to) {
169+
if (ip > ip_to)
170170
swap(ip, ip_to);
171-
if (ip < map->first_ip)
172-
return -IPSET_ERR_BITMAP_RANGE;
173-
}
174171
} else if (tb[IPSET_ATTR_CIDR]) {
175172
u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
176173

@@ -181,7 +178,7 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],
181178
ip_to = ip;
182179
}
183180

184-
if (ip_to > map->last_ip)
181+
if (ip < map->first_ip || ip_to > map->last_ip)
185182
return -IPSET_ERR_BITMAP_RANGE;
186183

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

0 commit comments

Comments
 (0)