Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1644261pxy; Mon, 2 Aug 2021 06:59:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys6/eUJWkFtGmWUqQ+HlAf0CtozkQVdiAYwXse6m+Uflmjvuq/09FGHlZ/OBgN6+HIhw5N X-Received: by 2002:a92:d70f:: with SMTP id m15mr866714iln.162.1627912757815; Mon, 02 Aug 2021 06:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912757; cv=none; d=google.com; s=arc-20160816; b=rQ6KTsbEAAwjVr42TMRIDQskz23B0+ypT0uyprbbBtSpnfuVm28CtGUTwgGMu4cza+ hhByB58qg/MhGWuksTibHTPH/+i4EtO9Gz2G8rK0hYPOE+XDXzHwDxO5cZy+8Kgaj47M u3SSPXuNbVsl5dH2H36ybaUAEwNBADHDcwkF7bhYiUitDsZTYBcPN2W+shMxEj6oTfx+ RBX1YA/8SlDC7urzMxGIsaEtnKNjEknuN+jsNgVW09i2sY3X6NaLnlpPfzGjmlSO+B9n fcKdGWGFtPqi1IbC4JGOMBIa8FVCPY8XHHcOz4FVSYaCwXIAx+aThOtBOy1B1oPxJNzw OWiQ== 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=evPloifvf4TZAL3ScmY/CqXtIWSfvgAELNh5+gJezr4=; b=zQdZUSo7Da4Y5GpdgVAlmeq/YccPX/5tBbq0cOjk4PeopqIF6pN7vnmdZAxgQW/PRE hEzQEJFUuU1hvPIVdqLePURrzNMZgMyWWbHmzCuExTwtY1HXjeamA2lqAIPA/CwWCmZ0 BskLHXd7HwJoOyc+xsf6ps37+Fz3tGKYHBbTCZkIClEwAeXcAZJKchNnbud8UhLNDnxJ f7/4PI7l7RlG7yErZX3RpD/KBNaJ68h0DqZ5lab8ruPNCcHEcEVUzH5UC20pdWsuxxhY 2yJiurY2kS9krHnoqy/liipKr/NjnYngNoBoUCHuAzioNRzmw4nugCDc7iOae4Y9k+57 1/IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=08Pd7rYY; 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 c14si13744993ilq.3.2021.08.02.06.59.06; Mon, 02 Aug 2021 06:59:17 -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=08Pd7rYY; 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 S235931AbhHBN5Y (ORCPT + 99 others); Mon, 2 Aug 2021 09:57:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:34430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234865AbhHBNve (ORCPT ); Mon, 2 Aug 2021 09:51:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 920BA60EBB; Mon, 2 Aug 2021 13:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912263; bh=vrVy1tdHGkVyIMDh8usfnUdKqBLUha627ue1VAYCnjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=08Pd7rYYTfAZaPdl9rFGebQd75omgfFfHET+HDK8EBaeM7bvQGlxOO3xURNpH6iaR ujTTbNCW4k1z+bwpUX6Gkdt4xEUTNfOxjkHTBmbhLCUg2ibbgQj79L6Rn/BdRzNnbz 0SGu2O405tzX4DDBy0pNtSL32Xeqgu+/NtXXQ1wQ= 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.4 21/40] netfilter: nft_nat: allow to specify layer 4 protocol NAT only Date: Mon, 2 Aug 2021 15:45:01 +0200 Message-Id: <20210802134336.065762007@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134335.408294521@linuxfoundation.org> References: <20210802134335.408294521@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 243e8107f456..17c0f75dfcdb 100644 --- a/net/netfilter/nft_nat.c +++ b/net/netfilter/nft_nat.c @@ -147,7 +147,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