Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3294808rwa; Tue, 23 Aug 2022 02:10:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR6fd2ZdtgY0ZFV2eqTvp/6FHAMf/1SdPBpF3xvRA+Ywy7k+mbLhu308fvV0GKh2IaM03juY X-Received: by 2002:a05:6402:238b:b0:446:5861:5b4 with SMTP id j11-20020a056402238b00b00446586105b4mr2821800eda.280.1661245823237; Tue, 23 Aug 2022 02:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661245823; cv=none; d=google.com; s=arc-20160816; b=YD8asuJRhNKDR+tEudy3y1HFVGXdb23gitjl8u25O++B/5RKg+VJgn0XAEDjIxUz+o Nk+YNr64r1cqYJOFWnJ6R0LELZpbSUFLxMUkyyFluLc3U+4AK9PB/Zo+2/IIzBxH+JWy NI4Aw0RGpSy5tQhCOlOU8Fcdi5DASQ/t4SulRDbZND/tcvvJ7SUx7u6gPii2IbUGyfpI MR4oQ5g/As7HjnmQsKQRfwNokIXMTB9qja7yI0tL/T8wi2Ui61E7bQ98BYPZb6F6foet TLggjKXKaqcJjmm3gMqksqUOmS3173Nd5lAQw9HjaggueJqu/xJMUKazSAIXDwow8tPW 4/Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V63TxdFyJplH4xruUJiGyiznDjuw+Tl3ZfSxMe0ADfI=; b=WI3XeoBUTX7ix9MVvyOIPNDyz+3urI4/JIjsS4ADgK2vCpI3d9hZTKUmVwCebEU72D mo7tflgvb9UnJmHa8zwpjk/fIz269HDTZnJXvFRMLVfSJV6qv9FNAwaXwFOZv7hrj9e5 r7cS25pPB6kZBBpPROc+L2PY+ln6rkuxljDVDdfsR6PtKYJn6cX88sv5P+XDSuXvD8iY 27pdY7PGprZha3tAytahgFTNAFpJZmMFGn/Aojuh4HF/UpkYqmyWIRysX34OBlDa45m0 NnN6r3MofEfHG+xDUjSaHCv8CKRdUpH26e5yp7Ak30dBsJtH6D1rVi3sLS4zFQbA2c0Z lS1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pLa9tzd+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd34-20020a1709076e2200b0073d63d9946asi7664430ejc.109.2022.08.23.02.09.49; Tue, 23 Aug 2022 02:10:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pLa9tzd+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241264AbiHWJFy (ORCPT + 99 others); Tue, 23 Aug 2022 05:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239780AbiHWJEp (ORCPT ); Tue, 23 Aug 2022 05:04:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E964A844F5; Tue, 23 Aug 2022 01:29:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4C5DCB81C56; Tue, 23 Aug 2022 08:28:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8136CC433D6; Tue, 23 Aug 2022 08:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243298; bh=ZkGlN9afaf+S8OZYrv31ANxjGxSlJNGR2VacqwOjGP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLa9tzd+W/XTh8m7gazwNXxhvCqCOeec3CyWo9FosXAv/b2zoHa97Yu1p75ovcWlv 0rKQNkDHjP4YTjPPGUP7tOyMJ9+5mirChPe7/nyUMK4lwLjMZGXJu/qA2OmJUJVam4 mqFIXfMwrtE91JwxYqIBmvITtFqvBV6sD7/KefBY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso Subject: [PATCH 5.19 202/365] netfilter: nf_tables: check NFT_SET_CONCAT flag if field_count is specified Date: Tue, 23 Aug 2022 10:01:43 +0200 Message-Id: <20220823080126.677720458@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso commit 1b6345d4160ecd3d04bd8cd75df90c67811e8cc9 upstream. Since f3a2181e16f1 ("netfilter: nf_tables: Support for sets with multiple ranged fields"), it possible to combine intervals and concatenations. Later on, ef516e8625dd ("netfilter: nf_tables: reintroduce the NFT_SET_CONCAT flag") provides the NFT_SET_CONCAT flag for userspace to report that the set stores a concatenation. Make sure NFT_SET_CONCAT is set on if field_count is specified for consistency. Otherwise, if NFT_SET_CONCAT is specified with no field_count, bail out with EINVAL. Fixes: ef516e8625dd ("netfilter: nf_tables: reintroduce the NFT_SET_CONCAT flag") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4451,6 +4451,11 @@ static int nf_tables_newset(struct sk_bu err = nf_tables_set_desc_parse(&desc, nla[NFTA_SET_DESC]); if (err < 0) return err; + + if (desc.field_count > 1 && !(flags & NFT_SET_CONCAT)) + return -EINVAL; + } else if (flags & NFT_SET_CONCAT) { + return -EINVAL; } if (nla[NFTA_SET_EXPR] || nla[NFTA_SET_EXPRESSIONS])