Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5641974imu; Mon, 26 Nov 2018 03:24:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/WW/wFKXC8KddtOjpgDbnXaGPIwMnXk6e9jev1+veSQuse2q3YnJbgZPvS1z5kzDvSV+Rx7 X-Received: by 2002:a63:6cc:: with SMTP id 195mr24609858pgg.52.1543231483362; Mon, 26 Nov 2018 03:24:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543231483; cv=none; d=google.com; s=arc-20160816; b=Sz6zcsD258UL5JT4o7vgl/18xAPcifMg/5C8yR1aojfVjFKCogct9N3xiMiwQ+PjjN +Qmx5lTOeaLzuTKJ5uI14xomgKBb5nNXAaiNALLf0Rfgmqb0NUBoahSxBgB9UDQCBwtk POdalejkK4URbOkQQfDr41I8K3kvOs0abjw48uYwo1fGPGumumfEV/KoTKXAsOBRI38d 41qS+A6vMEP7vB8Wr7kQnY12ch6waNbME+0a7KluSccwVQJtxuZ/ECtPc5KDfxAcdeGT 2b5zTYaIKz6RePGHux1DLUjbGX4uRwpY6vDYf1zSYGbAHIZaCyMypyg2SFyx3ttMTP5E ZTQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3rtJpazEDlbSFHG3S6+0JHNpZnlbeN7c1qZu9yjK0os=; b=H2HT2Dv7a8y0t4q6CDRMpLc5gxfael9JBMK6xAsv/IqH5TxxmzfgvxlGc0H/wEMUry ylRn7TOHDVp2noPpRy7zEakI9Q7IC5SdeirbnldZuCvdy7jJKOroU3ug6VFKRZ0zOq+R vekSCB5BukpdifgxIzi0fs7n9PnAULrNF1OB08/mogw2uTQWbqN8Ici/0Fggniu2wd18 bATNt1BvV1/+D+LejlnjFS51yPHfjC9oYHI+49dst/ghTZMnvv0j2dLDXquwju/42XXY vZwwx1EVne6FK5H5IxwrmHkou5sfB59RcQLm0btzA+3bASirnv63ZnUD+zUfCBoB8wtY m1TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YBsmbCI7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 26si15954pgu.190.2018.11.26.03.24.28; Mon, 26 Nov 2018 03:24:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YBsmbCI7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728381AbeKZVuI (ORCPT + 99 others); Mon, 26 Nov 2018 16:50:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:59240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726532AbeKZVuI (ORCPT ); Mon, 26 Nov 2018 16:50:08 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1A5ED2146F; Mon, 26 Nov 2018 10:56:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543229783; bh=tUi/af6knvffPf3TvTEuzrW31vjPRy3y+HP0mlMnvJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBsmbCI7lA0FfWTtj7CGchRx5uN9X03I6nAYD/1Bs1tUHn48Ksk0aTOcLvE4daTn8 m7t/jSjv5zdRxyBO8PL0vJ4lQZKuPjNMYFaEjhHgkg5hPH4zgkUgbrSYtAxiVDb5Sm T7YHdfAWmD/JVkvhkw4cye770klNb2624CZUoesw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Westbrook , Jozsef Kadlecsik , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.4 47/70] netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net Date: Mon, 26 Nov 2018 11:51:02 +0100 Message-Id: <20181126105051.549263236@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105046.722096341@linuxfoundation.org> References: <20181126105046.722096341@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 886503f34d63e681662057448819edb5b1057a97 ] Allow /0 as advertised for hash:net,port,net sets. For "hash:net,port,net", ipset(8) says that "either subnet is permitted to be a /0 should you wish to match port between all destinations." Make that statement true. Before: # ipset create cidrzero hash:net,port,net # ipset add cidrzero 0.0.0.0/0,12345,0.0.0.0/0 ipset v6.34: The value of the CIDR parameter of the IP address is invalid # ipset create cidrzero6 hash:net,port,net family inet6 # ipset add cidrzero6 ::/0,12345,::/0 ipset v6.34: The value of the CIDR parameter of the IP address is invalid After: # ipset create cidrzero hash:net,port,net # ipset add cidrzero 0.0.0.0/0,12345,0.0.0.0/0 # ipset test cidrzero 192.168.205.129,12345,172.16.205.129 192.168.205.129,tcp:12345,172.16.205.129 is in set cidrzero. # ipset create cidrzero6 hash:net,port,net family inet6 # ipset add cidrzero6 ::/0,12345,::/0 # ipset test cidrzero6 fe80::1,12345,ff00::1 fe80::1,tcp:12345,ff00::1 is in set cidrzero6. See also: https://bugzilla.kernel.org/show_bug.cgi?id=200897 https://github.com/ewestbrook/linux/commit/df7ff6efb0934ab6acc11f003ff1a7580d6c1d9c Signed-off-by: Eric Westbrook Signed-off-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/ipset/ip_set_hash_netportnet.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/netfilter/ipset/ip_set_hash_netportnet.c b/net/netfilter/ipset/ip_set_hash_netportnet.c index 9a14c237830f..b259a5814965 100644 --- a/net/netfilter/ipset/ip_set_hash_netportnet.c +++ b/net/netfilter/ipset/ip_set_hash_netportnet.c @@ -213,13 +213,13 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[], if (tb[IPSET_ATTR_CIDR]) { e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]); - if (!e.cidr[0] || e.cidr[0] > HOST_MASK) + if (e.cidr[0] > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; } if (tb[IPSET_ATTR_CIDR2]) { e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]); - if (!e.cidr[1] || e.cidr[1] > HOST_MASK) + if (e.cidr[1] > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; } @@ -492,13 +492,13 @@ hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[], if (tb[IPSET_ATTR_CIDR]) { e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]); - if (!e.cidr[0] || e.cidr[0] > HOST_MASK) + if (e.cidr[0] > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; } if (tb[IPSET_ATTR_CIDR2]) { e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]); - if (!e.cidr[1] || e.cidr[1] > HOST_MASK) + if (e.cidr[1] > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; } -- 2.17.1