Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3076149rwe; Mon, 29 Aug 2022 05:33:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR4SBxU55ffxtF425wRBSA3FVWynU3rkBsK+drHJ8h2O/4AjxeXLJ5nm0HbYUNi/VTyN1CyT X-Received: by 2002:a05:6a00:23d1:b0:538:1a9f:4c7c with SMTP id g17-20020a056a0023d100b005381a9f4c7cmr7183266pfc.16.1661776381395; Mon, 29 Aug 2022 05:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661776381; cv=none; d=google.com; s=arc-20160816; b=PLeEbjj0RNVlAlGdxJtrcNiiQ7aqmQfvcT98SAJhW4I8tQ7o7LUgmBKm1qfdxDD8kX talO1dfXPw7OkKesTLRAY1D3XbgmWPWrUWP5PaHAuEa1D4dRCZGvBs31X/U4HcMpJvdq qw6XAWBhZ1Brc3PHBqkDq2F3J5aImBmXrdRY0fg0W8CzpKn23Zl7DXO6DxuKbKV+0M5j vvvLpvIFAL7F4ib6BR4+bRitzAANu4IuSmcq13emUJLMuNUDpQ9dddwFD7LY62e6swTU R6O6XtR7cHirMjWaPc98jzfGTIMG3GXbh/wouHsKESdITxpQB/l7PKlyaA2sZhjAgEf6 BFEg== 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=ijoeTyHkd9Bom6Wo/NgMyud4IxpoULoaS/H4tjGJNrI=; b=zkMMClH+FnI5UOVd7Nneo2BFn8roSNjxmdJxGglvpBn8FNh5n0dC4R5WCPTIpkC/ql 74oZd1TVgehYCHimtIoCQa/6ruR3eixRfPO2ZU5PtHjlVYywKwKCoJXy3GNiFNl654pp pVciHwQQ7ZlDb5BBX2G/GpoAvODbu4BJeFo4mvIef59fkAkC59nMmAlmPFEnrhg/rhNa DtoC4J+L+aWeqUYuXiItv8wMLwWQnaBoRsEYKGlM1j8XoVHXAYhG12BYiAf7+PRxojjF nQc225T6roB/18qkw5Zt6HibTVfIgxIGdOsNmHBC0CbUqGn2kXyKUFu5KqBGN6zRVhm/ booA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TptvsbQ0; 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 ot4-20020a17090b3b4400b001fbbef201e1si9527610pjb.162.2022.08.29.05.32.49; Mon, 29 Aug 2022 05:33:01 -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=TptvsbQ0; 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 S231158AbiH2LLS (ORCPT + 99 others); Mon, 29 Aug 2022 07:11:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230439AbiH2LKR (ORCPT ); Mon, 29 Aug 2022 07:10:17 -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 632845F93; Mon, 29 Aug 2022 04:07:20 -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 9975BB80F2B; Mon, 29 Aug 2022 11:07:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8B7DC433C1; Mon, 29 Aug 2022 11:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771238; bh=M+k41fySf9W9qlUWewRVNfAONOL7YWGUa52LoTBbASs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TptvsbQ0xjcBJmvQDlyzpnrgN77+HW1QCM3Ydx/5VplKQ2kYtd+qrUshE9ALnM65C PSfJ9t6gN4JnJGkZ08X1XES14TH1/XLq6y2O9dQGkDtbJ+mbbEZoYFnRgB4+/o6yCS gOlyUyjM0wI9cQaAJuUDf4s1TmtbqgngTHI/vZ4E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 42/86] netfilter: nf_tables: disallow jump to implicit chain from set element Date: Mon, 29 Aug 2022 12:59:08 +0200 Message-Id: <20220829105758.265637135@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105756.500128871@linuxfoundation.org> References: <20220829105756.500128871@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 [ Upstream commit f323ef3a0d49e147365284bc1f02212e617b7f09 ] Extend struct nft_data_desc to add a flag field that specifies nft_data_init() is being called for set element data. Use it to disallow jump to implicit chain from set element, only jump to chain via immediate expression is allowed. Fixes: d0e2c7de92c7 ("netfilter: nf_tables: add NFT_CHAIN_BINDING") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- include/net/netfilter/nf_tables.h | 5 +++++ net/netfilter/nf_tables_api.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h index 6c062b2509b9b..e66fee99ed3ea 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -176,10 +176,15 @@ struct nft_ctx { bool report; }; +enum nft_data_desc_flags { + NFT_DATA_DESC_SETELEM = (1 << 0), +}; + struct nft_data_desc { enum nft_data_types type; unsigned int size; unsigned int len; + unsigned int flags; }; int nft_data_init(const struct nft_ctx *ctx, struct nft_data *data, diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index df79ea6004a59..b36728cfc5d81 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4865,6 +4865,7 @@ static int nft_setelem_parse_data(struct nft_ctx *ctx, struct nft_set *set, desc->type = dtype; desc->size = NFT_DATA_VALUE_MAXLEN; desc->len = set->dlen; + desc->flags = NFT_DATA_DESC_SETELEM; return nft_data_init(ctx, data, desc, attr); } @@ -8677,6 +8678,9 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data, return PTR_ERR(chain); if (nft_is_base_chain(chain)) return -EOPNOTSUPP; + if (desc->flags & NFT_DATA_DESC_SETELEM && + chain->flags & NFT_CHAIN_BINDING) + return -EINVAL; chain->use++; data->verdict.chain = chain; -- 2.35.1