Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1639950pxy; Mon, 2 Aug 2021 06:52:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzraNnYLn1XOuf0Tgs5CTat1UkI8yJ4n0XNFU3CleaA3NhSED97bTJai0f65WPS9oi7I2rc X-Received: by 2002:a92:c68a:: with SMTP id o10mr221712ilg.112.1627912341021; Mon, 02 Aug 2021 06:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912341; cv=none; d=google.com; s=arc-20160816; b=n/D335eHK+feaqHon+e0YW8cxAx+zNwU4HHCL197DEdYuDjH1XOZa+TnyOt0551+hY Dy8tGR91QQdVPqxI+lKe9G2H2ssBKODl2AwIH7BAv+I1LIsiyxxBtaRbfJJi3bTuDECP vX6HuS6v/jFr0rNCkBApYxb3UOa9xxLTSu/nHzuHW4M2zRD4FoLqbEEcJce61MfYOo4h bz7ooYbibutJJXh6r86XjoNr7bxYeKJ80TmlgZnB/MJGYKbc3nF9ymFS+cirTcMXfxJ4 CXhaeCKU9poRuKC9vKDMpvCWIMOVfoo6o6qJK+YN9KTqvbWPIgqgIHLkg22z5Qx1xSkL gKDA== 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=9uImc9u+h9MbsE6wds4xxDJgk/zVCetzcKXdpFq/cuk=; b=qa5mZ8rlk/dIwt6KzwXL8vI4fjsKJSpJwcLAwAuiN89uD7EMYGh48QF3qOvvAYB2+6 VjHjxAk3tpEDpU0b99rjTrBE51ErFVztmxE7Af02Pi4cF/qlOA8ARQbUDkiIb1vIVVNX cskabYD6pXG6A6JZeL6KYFPFSNNgSCDtXG9RW+1ITtzA8v4mLmIZIOkHtK1tD/G3bR99 gabLrglCOsbdishU5sU+zJMEUqGtRIHTmmN8zKDeXmmMrHGLmdS7yneiah58hmEba9ET mXxxCn/3m1/Cfd2+5gBFW7JTX1pEihZpzjLOCkCaXLXNGWH3I8C7QMQxsmoCoSATYE8W jyNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qUoxLgaM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si12475120ilq.43.2021.08.02.06.52.06; Mon, 02 Aug 2021 06:52:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qUoxLgaM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234284AbhHBNvi (ORCPT + 99 others); Mon, 2 Aug 2021 09:51:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:57096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234143AbhHBNrs (ORCPT ); Mon, 2 Aug 2021 09:47:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CE1CB61106; Mon, 2 Aug 2021 13:47:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912052; bh=8G3Wb+6OXBJJ4C+pVYqw5cEC5/+uqdpJgwVsGIa16sc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qUoxLgaMhmG0MtpIk5a5mugFjWgU6HHmbe8ywl3545Lu9dqMMy1yJNyKASRAOxjYG 03Is19+cEvPc+z5rDdDwQxH2ubnuCu2JU7SXTL3o22YWM3T5qw9A2BDt3aDqdlwoSV J/ReJzp+vLOYGzcFtCrPCD2AX1i1M3IDLobMYAEU= 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 4.9 26/32] netfilter: nft_nat: allow to specify layer 4 protocol NAT only Date: Mon, 2 Aug 2021 15:44:46 +0200 Message-Id: <20210802134333.748856187@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134332.931915241@linuxfoundation.org> References: <20210802134332.931915241@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit a33f387ecd5aafae514095c2c4a8c24f7aea7e8b ] nft_nat reports a bogus EAFNOSUPPORT if no layer 3 information is specified. Fixes: d07db9884a5f ("netfilter: nf_tables: introduce nft_validate_register_load()") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_nat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c index d2510e432c18..d338d69a0e0b 100644 --- a/net/netfilter/nft_nat.c +++ b/net/netfilter/nft_nat.c @@ -157,7 +157,9 @@ static int nft_nat_init(const struct nft_ctx *ctx, const struct nft_expr *expr, alen = FIELD_SIZEOF(struct nf_nat_range, min_addr.ip6); break; default: - return -EAFNOSUPPORT; + if (tb[NFTA_NAT_REG_ADDR_MIN]) + return -EAFNOSUPPORT; + break; } priv->family = family; -- 2.30.2