Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5637532imu; Mon, 26 Nov 2018 03:20:47 -0800 (PST) X-Google-Smtp-Source: AJdET5feXWpOp2ruIA7IjfrIWrn0Niw++iC/if9EATUCDjiiYy18BDu64Dg0W756cHkF7Mt5Q+rj X-Received: by 2002:aa7:87ce:: with SMTP id i14mr27286332pfo.20.1543231247558; Mon, 26 Nov 2018 03:20:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543231247; cv=none; d=google.com; s=arc-20160816; b=iO+GM0gXWo6C4ujTiTIDJcM0kOSYgD0PeJPY0ttc6sQ+YgGND2FdKI9YJI5Smv07Wt IGIWAt1WHvkVdMLfDhf5rRgcXzYeJyFXwVHD7iIXAIZixqj7JDY1TqsGRjq7DYUDGVvs PBeWPjXLXbVZPtmqiebeX7IASXJUxiXmG5BWoJWEow4arjgY5v5lOXw/JLX99g36OHzx G8opvrbAXNt345P0XR+MuDvlKgdutnLbkIa1+cF3w75OqC16zX45iVzeugxEVHSAoeFW 4q72iDC5HBE8HJ04pf4l92wGzm5A2dmgPahlbJJtyBgPPHcp2aVCV315EinROn7TfAad W6tw== 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=HJ4o2aRs6gmjP5++sCHzyTN+SLQvvAoOuyN2MVMPnw4=; b=XT+0m5WVKxHlNcRXOC4qXoxYFNPhVe2swO274WcjAR3CidJ0Ky0yfkdxF/UZP5H5x4 UyqccbBOoEdlOrETlGCeS5174m/u7O2LEYimIwZ1cdIQeuOk9mPzQWX15jxHSO3hEX9K EzDMC6VF4ASBbq5nhhSOyS/FDKC3d2Yt81/xr36cuunEz3cYOJCswP1oYZn/GVGS/jOB o4Xsf4e4l6zFINU6TS3z/NYPnrQ7uVRfHHwRlQ7wL+29oBdAX2YnhFmf0g58b0LLH7/x viK3nGVxWLmYC0g+Bi1EXYC2ezl5hoNa3U1RpZPTlEzP8dGN2OrBRzvE0wIfTp1wYsR/ tR6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ja8w6aUz; 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 b128si17177279pfa.283.2018.11.26.03.20.22; Mon, 26 Nov 2018 03:20:47 -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=ja8w6aUz; 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 S1729552AbeKZVxQ (ORCPT + 99 others); Mon, 26 Nov 2018 16:53:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:34946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727875AbeKZVxP (ORCPT ); Mon, 26 Nov 2018 16:53:15 -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 B2BBF2089F; Mon, 26 Nov 2018 10:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543229970; bh=CSuJ8/+IhKk0cvsGL82n6K9ra4GeK139sw5sVk4Rr70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ja8w6aUzEq4EOARQW90qMPpAje5rh9h9lhiTJXNoyAtWqS6585rHtne5B46box81l H+3VV224kbXguDAN313eH4bHr1+Pu5qzwGPFewt1z1gaTmg1hDKDFA9mzLlOv6ugdy XiXa3J4lrOtsnoIQEC0FFDH/rSVCm2q/5tdHlnxo= 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.14 22/62] netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net Date: Mon, 26 Nov 2018 11:51:03 +0100 Message-Id: <20181126105052.656943752@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105050.592727680@linuxfoundation.org> References: <20181126105050.592727680@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.14-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 8602f2595a1a..0e6e40c6f652 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