Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3026412rwb; Mon, 15 Aug 2022 16:24:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR7GZS7mHDaRt8Gx4icdtdtMoloETX443OhEl3UYUR1uQORm9vW8d5B6kUCqeKzGWj0imD4f X-Received: by 2002:a17:907:948a:b0:737:4df4:2370 with SMTP id dm10-20020a170907948a00b007374df42370mr8014845ejc.264.1660605870582; Mon, 15 Aug 2022 16:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605870; cv=none; d=google.com; s=arc-20160816; b=pSXrNCrofvUL4b3UP7camKZtEfYMTA/9PlbUyqduQurdiCj20+sxk6KNAkk1czlgvf okKfVsfU0dycyfX6LQ1HHXfJAyEOhxyLTY9Ce2PMKBgFuTP29MCzfE2Ld81M2/31WPgb B4ZHAt2ragDg4q6MZtJgKQLdPr26rZN/qXE0yuqnLh8BqWcOnRjzcaRQYBEGA86R9FeL gQUs4q+vQUX4eLW4Nhbug4Nt6BaIyKYXUhqAPsZh8Up/dohl8IQQgCmswfAdxluVaWZZ KM6MVJNvRh/L4V31EI5zJTrfqsBE48BB8xhabtS756Nev/r2fAiZNtWCUmPr3PfKpcW/ ZXhQ== 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=xb8jo5rsIKmyVclqMoawSSSdqqEKaX0jPHch9hyzHKY=; b=FVmloJ6mV1lPcT6z1vjJqT5qhwza2pOnEL57dYBgmQBnJP2QXVi7jKHJr2d/NknTWq 55NLOdMrHlaqH8nvg9MnR3+boS1asJAgQ5Vh6uTuXh7H2aulGR2N0TPWgvu9FIV3UQsH y2D/2Hl+mdcFOPR6f+/kFvQCFxM6+oXOaDPAuy+aOlE9sy8fBcuPtBLZP9yGd9w/yssZ hZ5d05H9/Ud5gb0C5ll+hKNspcicZetgMGxIaNXYPzN4A2Am7ru3CYg4cLchLddOiC6B r7bJAP762zsAdJg/bZkTaHTAQIfyRgXs/FcFCvukWJ9oA+AUwRAiBj8OEJLfwfYZlrvE 0jaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DBJSlpB9; 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 hp10-20020a1709073e0a00b0073040248a76si8575160ejc.700.2022.08.15.16.24.05; Mon, 15 Aug 2022 16:24:30 -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=DBJSlpB9; 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 S1348366AbiHOWaE (ORCPT + 99 others); Mon, 15 Aug 2022 18:30:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348287AbiHOWYv (ORCPT ); Mon, 15 Aug 2022 18:24:51 -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 63759125D73; Mon, 15 Aug 2022 12:44: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 9F724B80EAB; Mon, 15 Aug 2022 19:44:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E440CC433C1; Mon, 15 Aug 2022 19:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592658; bh=sWem4P/NPWh3xaM32TtZWFwItHMbGgeKGUW+8VSoeHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBJSlpB9CC2IdruCRC4QImZVt3fYWMqmlbZlEXVph1i2w5f9FiffLSqCGMgJSVMnm +tPjF2i6MDWYQJWSM4NcEqtySImO+nPPR6MUdi58q+fRx1Bv5jcIHA2rUrQKTRlk+c TRJr/uVPN+mLmLYTWV64lrehVodWw6MCmwzpOXE0= 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 0144/1157] netfilter: nf_tables: disallow jump to implicit chain from set element Date: Mon, 15 Aug 2022 19:51:40 +0200 Message-Id: <20220815180445.395122647@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 f323ef3a0d49e147365284bc1f02212e617b7f09 upstream. 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: Greg Kroah-Hartman --- include/net/netfilter/nf_tables.h | 5 +++++ net/netfilter/nf_tables_api.c | 4 ++++ 2 files changed, 9 insertions(+) --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -206,10 +206,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, --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -5226,6 +5226,7 @@ static int nft_setelem_parse_data(struct 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); } @@ -9611,6 +9612,9 @@ static int nft_verdict_init(const struct 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;