From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AA441514CE; Fri, 6 Dec 2024 15:16:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733498175; cv=none; b=SMzFwRt5wDbail5In1m5KtrDZ/Uqzm2QM73fCzs/vxGvkhsxuRcvXfsSuGTZI8IDmML0jLgFbu8qh4kBz8o2mOu3mWBuPwC8I7ZeKgPQOGuJnSEQ23djWUBYL2G7FrbxT6wTBHoInKCgm8h7lYPuHmCuv09ycpG3t9jnJ1p8Syk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733498175; c=relaxed/simple; bh=Gj/k9D2fDsFGv8J3mDiCrhlgMRLrBF1VOLBCgm81RJg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RroLAACQqIkJKRaKu3g59/EktkUu0nlzvcUhvYbgrzIz7up9zDTQK1qnELmLbsxZZjfESJH7Bt6cib9dT918hlOFopBiAA+Hj60d0/Umg1MYHW+AMpS0HTYAc3OUrqEWgngus/F9QXWpjzSDdc3N78sTbPI4gV0exJGQWbwdKNg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1uvM/PkO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="1uvM/PkO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AB05C4CED1; Fri, 6 Dec 2024 15:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733498173; bh=Gj/k9D2fDsFGv8J3mDiCrhlgMRLrBF1VOLBCgm81RJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1uvM/PkOZ3E6nrw//Gl+EUYbFoe83hRO5z/uZoke0P7v1nIEq9RyWAmOMfHYVGjE1 DdtPxy7VczaF4S74l2Z5p88CqtNPqzYOyuNOJN1h7lFMKi5PfPdZb/ZBJJb7JDbMVu V4IUuzOsXDt+8y2S8v+jF3AdDgrz7NWu3pC2/6nw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+58c872f7790a4d2ac951@syzkaller.appspotmail.com, Jeongjun Park , Jozsef Kadlecsik , Pablo Neira Ayuso Subject: [PATCH 6.6 506/676] netfilter: ipset: add missing range check in bitmap_ip_uadt Date: Fri, 6 Dec 2024 15:35:25 +0100 Message-ID: <20241206143713.120318050@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143653.344873888@linuxfoundation.org> References: <20241206143653.344873888@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeongjun Park commit 35f56c554eb1b56b77b3cf197a6b00922d49033d upstream. 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: Reported-by: syzbot+58c872f7790a4d2ac951@syzkaller.appspotmail.com Fixes: 72205fc68bd1 ("netfilter: ipset: bitmap:ip set type support") Signed-off-by: Jeongjun Park Acked-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/ipset/ip_set_bitmap_ip.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/net/netfilter/ipset/ip_set_bitmap_ip.c +++ b/net/netfilter/ipset/ip_set_bitmap_ip.c @@ -163,11 +163,8 @@ bitmap_ip_uadt(struct ip_set *set, struc ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); if (ret) return ret; - if (ip > ip_to) { + if (ip > ip_to) swap(ip, ip_to); - if (ip < map->first_ip) - return -IPSET_ERR_BITMAP_RANGE; - } } else if (tb[IPSET_ATTR_CIDR]) { u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]); @@ -178,7 +175,7 @@ bitmap_ip_uadt(struct ip_set *set, struc ip_to = ip; } - if (ip_to > map->last_ip) + if (ip < map->first_ip || ip_to > map->last_ip) return -IPSET_ERR_BITMAP_RANGE; for (; !before(ip_to, ip); ip += map->hosts) {