Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp856493pja; Wed, 1 Apr 2020 09:55:48 -0700 (PDT) X-Google-Smtp-Source: APiQypJL8ZhE8EY+M0w9UCA5sNxsBGUkxtHrGIBaxf2d049bQic4/5y9GRpj7cooN43w4c06dp5U X-Received: by 2002:aca:b308:: with SMTP id c8mr3354720oif.106.1585760148191; Wed, 01 Apr 2020 09:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585760148; cv=none; d=google.com; s=arc-20160816; b=TsFqYENzU4Ltft3KEjP7Hjciqmd5UnT+NYJhYwvw7uVb23ciGeKbB5sRig0TtglYIc WN3kYiq3vtC8+X3wDuv0N34DBbLpKDdYF8O9Gr9nvU7QLOx9Ii4urWoFkaeEDiE804To 7KQXLP9JejGIMl4lkcJqA7TEB/YrtBuG81OcpjroSLwicWYos+aQjdi0yGxHale8iiY9 SE0YdxkNEny4U+dse7qf/bT27YhLSbqkPjm0gW8nrQkCfTcapzAknCILXYenNXL0z+jj fpjzmS+54hWOTe3g4uG8jZ1iyeq3DHEniv1mYsfou7xFQF1Rj8pgZhfAZ9bTwnNNTDjE UjlQ== 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=1r2SB4O3K9YgyHyBwTJVCdthf71pOC9BEPoygt1v9tw=; b=z7v0SP4aRn6fvrP1pFfwHqBfA+EKQJs0T1FIT9FNlDszfnCccTsEPNe+OIJgSaIwAC ckcf4HsuZSEUdireOaWkkKzR87fFSYJc0jQCDTX21sc4B1UNoOHzQG2W0R4oWKZTSJDP 1AgHApJ+Abs/GWWKPZebPieFYvTq7DV9bs4iKLBAzFH+vprX+ACqL4Di8mGJ91t9f/05 OR7u9LZQjU1g7/DN2AR3Pirjy1lwrom8F+aVINEGNVaWUIHl/l8QzfEfO0Ku8hyEOJ4L k6IKCTNK2j0AZ/7/2n/BGH9wMNXDLjxPb5cL7B2PDdGo4hDxsorAI5R3sImEvLOSaVso jZuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EZaXmNcT; 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 q196si1096440oic.143.2020.04.01.09.55.34; Wed, 01 Apr 2020 09:55:48 -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; dkim=pass header.i=@kernel.org header.s=default header.b=EZaXmNcT; 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 S2388022AbgDAQy6 (ORCPT + 99 others); Wed, 1 Apr 2020 12:54:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:50944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732368AbgDAQ01 (ORCPT ); Wed, 1 Apr 2020 12:26:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 B693021556; Wed, 1 Apr 2020 16:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758387; bh=nNt8enatMWJnw9ROJBeIzsfYeGO5CjoIBWXwR3psAfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EZaXmNcTLnmE7EcVqGU1usxro/n4lIEVgZ3v7mjE30DueFYp+0fm5YcTPs2gonzMJ BMuWVoUOBHeb3FCMCUjoGx+tOad67P6Q7ky2kw72vtXCHg1vwk6vWDhHcbBp0R+aQy InBPLQuTa0mdP2IJt7nkC3VzlfuGUb2HrHFWTj0c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso Subject: [PATCH 4.19 073/116] netfilter: nft_fwd_netdev: validate family and chain type Date: Wed, 1 Apr 2020 18:17:29 +0200 Message-Id: <20200401161552.228574839@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161542.669484650@linuxfoundation.org> References: <20200401161542.669484650@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Pablo Neira Ayuso commit 76a109fac206e158eb3c967af98c178cff738e6a upstream. Make sure the forward action is only used from ingress. Fixes: 39e6dea28adc ("netfilter: nf_tables: add forward expression to the netdev family") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nft_fwd_netdev.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/net/netfilter/nft_fwd_netdev.c +++ b/net/netfilter/nft_fwd_netdev.c @@ -186,6 +186,13 @@ nla_put_failure: return -1; } +static int nft_fwd_validate(const struct nft_ctx *ctx, + const struct nft_expr *expr, + const struct nft_data **data) +{ + return nft_chain_validate_hooks(ctx->chain, (1 << NF_NETDEV_INGRESS)); +} + static struct nft_expr_type nft_fwd_netdev_type; static const struct nft_expr_ops nft_fwd_neigh_netdev_ops = { .type = &nft_fwd_netdev_type, @@ -193,6 +200,7 @@ static const struct nft_expr_ops nft_fwd .eval = nft_fwd_neigh_eval, .init = nft_fwd_neigh_init, .dump = nft_fwd_neigh_dump, + .validate = nft_fwd_validate, }; static const struct nft_expr_ops nft_fwd_netdev_ops = { @@ -201,6 +209,7 @@ static const struct nft_expr_ops nft_fwd .eval = nft_fwd_netdev_eval, .init = nft_fwd_netdev_init, .dump = nft_fwd_netdev_dump, + .validate = nft_fwd_validate, }; static const struct nft_expr_ops *