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 17DA11F1313; Tue, 3 Dec 2024 14:39:24 +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=1733236764; cv=none; b=SLwoU/rQ1y2bjWljssJqEmFVPcscjKzAB5XJ5jXc3xj5dSSLHiqi2HW8fnu9V11IVZOaRCtyvDKWbs/ickzmPeQ3siKoEwdokLpqyBnoz+z3qkFZMJU234Rkcw0LiRUwUliwFTChzx9/sQGHbdjSxs/AOgdgF55dZuXmj2gw1Ag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236764; c=relaxed/simple; bh=ZBiyf/l4HP+5v16GlG90QY0JYH5vyA345AQmQkQuTA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jvYoOpVPB9MY5tslhcBmvQ6M2hQzmSRdbkDqvjlJMY/1+KM5ouLzklMzXexUH8d5OLJMvyUvN5eWU2ZDXqZxv7bOwKEV0iFyKYhUJ2Pfnq/X0VsaRT4bvCaAhlexKIaA3WaWGTRMq5Qh28zQ61FChwEoqYJIWO2KaaaXKtlou1s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=w8NYZn1L; 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="w8NYZn1L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EBE8C4CECF; Tue, 3 Dec 2024 14:39:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733236763; bh=ZBiyf/l4HP+5v16GlG90QY0JYH5vyA345AQmQkQuTA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w8NYZn1Lct+olroq3o9UypQV1yPAvs6t6Vw3WpOD6fY8eanu5Do7KMj5jZ9r4rXDt MgGz1BceDw7WRULtwlMC0pjkGT00RJ1gHOR+MJVjMHgtWW5/+HiRkQrumiEZzAwd86 dWtOhyFWBQh4bRLbWYx5Sfi2uSWyjqBiI1CcZbD4= 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 4.19 111/138] netfilter: ipset: add missing range check in bitmap_ip_uadt Date: Tue, 3 Dec 2024 15:32:20 +0100 Message-ID: <20241203141927.812539648@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241203141923.524658091@linuxfoundation.org> References: <20241203141923.524658091@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 4.19-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 @@ -166,11 +166,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]); @@ -181,7 +178,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) {