Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1148430imm; Wed, 1 Aug 2018 11:00:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf/mLwBqRk/f3QuxeL92N8If/4mkUfffalhLh3fxacgV7tVSBAP+9NJGVKEyvqqkFn1b5kk X-Received: by 2002:a63:5866:: with SMTP id i38-v6mr25522599pgm.63.1533146415558; Wed, 01 Aug 2018 11:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146415; cv=none; d=google.com; s=arc-20160816; b=ojYOtkBdLrdOWMqypB/UaClzoKOSKh17tk0g3ftIwSKm9eubsMLSsusVVULCk9RAbM p7IFviejKGD8HUUsEr+HjvqRNjrBQ27y+UY7KlAmG8sc4pqnzT7Q5xL4zsFbsRvu1bSg fOhGJpvWRbSwrnf0zDEqHeOJWeWhaQk4iIktS/wM+2LoVeyTKqhodGZDYTP9fQV/K2A0 60tasSmHNxE3dQtCbht9GAGDe06h/hxp6+MxMsGRVtlwJZv8Xp4VMyLq6lQMydCSHtwF ZBp+9lNlTKSNCN2fNSY47G/fT7k0WDJbTrYwF38IGbSxl6W2w8Nx2KdzyqxiGR78rv2K KPIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7fkIEJf3iAa/n5aNUH6NOet2OTIpaMNmKINckdf+AEQ=; b=ahSX0g4tmwpzeb5taABR7fgqg2r3NVtCXWhh7CW+N/0FHPQlv9yCyEGsCo+Oz8qyqE JeO5GWUxZxBfbVQSPIxYPOIB6i7vQvS35xsF9D+K+S6CvxPRdWvcSvovHEe/kMf/Xswm mNpZ8wGPd5su6NZ6wLuwYBV86xgBurOwPabSDEg19zKdUUPR6AEbl00HUU4V2KIU5u6a sdoLzIbZ/P/LPBXK23ak+1oTmgOsk9ZSr2QuOf/CYqsXLnwvG2eeZE8HYaivsJGe09Z8 3tVakKVd7jz7p4Q0LC2j9m808B4lg1NJ3H/tBuijjtxkkCtJ930/8tEnu4QvTgEfNDvm zGlg== ARC-Authentication-Results: i=1; mx.google.com; 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 d11-v6si17391892pgh.564.2018.08.01.11.00.01; Wed, 01 Aug 2018 11:00:15 -0700 (PDT) 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; 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 S1732320AbeHATpR (ORCPT + 99 others); Wed, 1 Aug 2018 15:45:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50242 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405928AbeHATIj (ORCPT ); Wed, 1 Aug 2018 15:08:39 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D81E91360; Wed, 1 Aug 2018 17:13:19 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florent Fourcot , Victorien Molle , Jozsef Kadlecsik , Sasha Levin Subject: [PATCH 4.14 037/246] netfilter: ipset: forbid family for hash:mac sets Date: Wed, 1 Aug 2018 18:49:07 +0200 Message-Id: <20180801165013.456059346@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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. ------------------ From: Florent Fourcot [ Upstream commit cbdebe481a14b42c45aa9f4ceb5ff19b55de2c57 ] Userspace `ipset` command forbids family option for hash:mac type: ipset create test hash:mac family inet4 ipset v6.30: Unknown argument: `family' However, this check is not done in kernel itself. When someone use external netlink applications (pyroute2 python library for example), one can create hash:mac with invalid family and inconsistant results from userspace (`ipset` command cannot read set content anymore). This patch enforce the logic in kernel, and forbids insertion of hash:mac with a family set. Since IP_SET_PROTO_UNDEF is defined only for hash:mac, this patch has no impact on other hash:* sets Signed-off-by: Florent Fourcot Signed-off-by: Victorien Molle Signed-off-by: Jozsef Kadlecsik Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/netfilter/ipset/ip_set_hash_gen.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/net/netfilter/ipset/ip_set_hash_gen.h +++ b/net/netfilter/ipset/ip_set_hash_gen.h @@ -1241,7 +1241,10 @@ IPSET_TOKEN(HTYPE, _create)(struct net * pr_debug("Create set %s with family %s\n", set->name, set->family == NFPROTO_IPV4 ? "inet" : "inet6"); -#ifndef IP_SET_PROTO_UNDEF +#ifdef IP_SET_PROTO_UNDEF + if (set->family != NFPROTO_UNSPEC) + return -IPSET_ERR_INVALID_FAMILY; +#else if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) return -IPSET_ERR_INVALID_FAMILY; #endif