Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3288159ybb; Tue, 31 Mar 2020 02:09:49 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvSmZcTklQ1C+xWAUQGy1NQbMXj7dor3uh4rosALIzVIuZ3uYynU1dhx7ajgXpLCpQOykAe X-Received: by 2002:a4a:3357:: with SMTP id q84mr12519896ooq.69.1585645789852; Tue, 31 Mar 2020 02:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645789; cv=none; d=google.com; s=arc-20160816; b=W0WKrc8UdzLhXx12O9e2ztiyi3XlYSNUk7tfWYNougctOdz0srfU5XdgStdkHwjRGQ bAtxa5ok46Os/bfPJOyKcrC9QWReaByphRalfO0gsojLs2Vi0kW+0wfVmMw3BRx6Sqzl BhCLx94cskTKtGxt0Idw/uixvElfWwjcqjSNbfCmIb8LepXIT0sGjnV+FUyDkPT9+whX +nUvWoWhwtlEOe9ObzW9/5Q/Z8Sd8Z2S2kzLNEyL6TKaKv7grlrCRLkq92UBpcSnulFJ ppf8P5pyqjU/kS7tJEyWAJGYDx/Vgvj+N3M3jWBnv0Q7xvwBckNAy22J1z2Ufie3Uvvx d5xw== 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=KrY5HM4F0i1LxJIYYd03k/92Jec4Qi0gGuV2yM9QDZE=; b=MFb4FtZsrK7VOV3XvPcs4/tBrJhoBsuzVerd+TcpQIlVK0x1czmR42XgV50cQ0TO1O oN2lx2tAA8QnLAthLkpKe/VG+DJdKi6RJCMpWtMj7pwlyFOClrlCUJDLcsR5FGdEgmad 03ThFLOm1JRnlNfhg+h79RDosDTNAXAu1NJLjgZ74zj4QLdNqa4GTwxYs1oO/jN8Jowm mlYdUPXDSBVq4YIR+7vvdUJbDEOziFAbl3G9h0LCGVZoAjB1X68ziWBe+zaazkYeRMyX UpD5/gZpesKMO7p9ffhdCfnohs7DWv0gvREmY69FN5JdqCbd0fIOJv9PssoHjydbYZMo +4cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NX7boGC3; 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 k39si6243123otk.255.2020.03.31.02.09.37; Tue, 31 Mar 2020 02:09:49 -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=NX7boGC3; 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 S1731228AbgCaJIY (ORCPT + 99 others); Tue, 31 Mar 2020 05:08:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:50758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730905AbgCaJIW (ORCPT ); Tue, 31 Mar 2020 05:08:22 -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 B883F2072E; Tue, 31 Mar 2020 09:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645702; bh=mga9ZlB7EBqybPtMS1PRXb7f40tCX4Df5PKMdx1hR/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NX7boGC38wc/9Z2Fda4u0fJ8sWDsEzx9418zUUO1D1QJw75DIlQB8TdHWR+QOZ3a4 t/UJBdePpD4weksC7sQmt5eGZ9DcHVarrC3EZFX9oNk9EF21++zIN2Z4EmUDfh23So 2BxBl8qaIK1FwbFn1d9ni1Iami8F6Sbot7yW1tes= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso Subject: [PATCH 5.5 137/170] netfilter: nft_fwd_netdev: validate family and chain type Date: Tue, 31 Mar 2020 10:59:11 +0200 Message-Id: <20200331085438.071269661@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@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 @@ -190,6 +190,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, @@ -197,6 +204,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 = { @@ -205,6 +213,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, .offload = nft_fwd_netdev_offload, };