Skip to content

Commit c2c5bfe

Browse files
committed
netfilter: ipset: add missing range check in bitmap_ip_uadt
jira VULN-46557 cve CVE-2024-53141 commit-author Jeongjun Park <aha310510@gmail.com> 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: <stable@vger.kernel.org> Reported-by: syzbot+58c872f7790a4d2ac951@syzkaller.appspotmail.com Fixes: 72205fc ("netfilter: ipset: bitmap:ip set type support") Signed-off-by: Jeongjun Park <aha310510@gmail.com> Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> (cherry picked from commit 35f56c5) Signed-off-by: Anmol Jain <ajain@ciq.com>
1 parent 6ae0e11 commit c2c5bfe

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)