From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 429302EEE7A; Tue, 23 Jun 2026 22:16:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.190.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782252966; cv=none; b=d9WQw3ws1+eIAWlKs4ERVo5qEbXceG7Wl2YWe+aBewhMJA0oDuPi4T2q2ScVlUQzyU2TboArE8WTBb2zFCS4Z2rWtNEPXTxWUvLYOb3gXjZsKVxhleMAAiTWAzuL7Tvn1A+WOjkuhSQbuxt5oPBpYSRD0ta73+eyA1V1JhS5Gm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782252966; c=relaxed/simple; bh=ynRKfDMhgcoZRx3+yqyFiu9qzTBJcXNBKVKzDp0hlHA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c/TLNm0980rrerk3x9DuXCpk23GxOuVzakVJOHWWsVKutiiQCeSTTAcbwPyJkjO3cEfKNO5OIuHUxBRdSw4EzMyUuNRRHrbx3xUFtUGQCgBUN+hQRg9UuhzT0275jrNZcBbWSmq5QuP4YzuZirpbCbDoOaSl4KxFc5MFsaxCjyE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b=SoQ7u4HW; arc=none smtp.client-ip=217.70.190.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b="SoQ7u4HW" Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id D93F960580; Wed, 24 Jun 2026 00:16:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1782252962; bh=1rPtxmocEhvqPiU0H3vJyzJF55/SrpvG7Ce1UvyAuTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SoQ7u4HWTCRIoKNkng/FEiB3UC/Bifddjv8B65bxRv3MM9lQI7msU28bcGi0KkFS7 3Ktvt4zdO1yD7EXN75KdXHTcv09M2W1pWA6grA5GQW+LS4mbBNdyJCljNRpNIDCXu3 1hnprb7vEWkC5ZC5JAv9iYbwlWFYIdLVmc+8hNEZ8YO3+2VMXX7JTPzHm1h7tfrF6W NYO7vcCRnYNw4gnzaM5mB3VwmDL5fLoWKff7N2QeF/fo48wtWsD1wKUhmpcu4ajmgi m82RIh2EBCC7LGPVQHgi1nHNs4lXM8WC7zaVFbm+6OL4GVy1KgdkW+NwmgydEFSI6C LBOzDfWeh+99Q== From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, fw@strlen.de, horms@kernel.org Subject: [PATCH net 07/14] netfilter: nft_compat: ebtables emulation must reject non-bridge targets Date: Wed, 24 Jun 2026 00:15:40 +0200 Message-ID: <20260623221548.701545-8-pablo@netfilter.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260623221548.701545-1-pablo@netfilter.org> References: <20260623221548.701545-1-pablo@netfilter.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Florian Westphal xtables targets return netfilter verdicts: NF_ACCEPT, NF_DROP, and so on. ebtables targets return incompatible verdicts: EBT_ACCEPT, EBT_DROP, ... We cannot allow fallback to NFPROTO_UNSPEC. ebtables doesn't permit this since 11ff7288beb2 ("netfilter: ebtables: reject non-bridge targets") but that commit missed the nft_compat layer. Reported-by: Ren Wei Reported-by: Wyatt Feng Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Zhengchuan Liang Reported-by: Xin Liu Fixes: 0ca743a55991 ("netfilter: nf_tables: add compatibility layer for x_tables") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nft_compat.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c index 0caa9304d2d0..63864b928259 100644 --- a/net/netfilter/nft_compat.c +++ b/net/netfilter/nft_compat.c @@ -397,6 +397,22 @@ static int nft_target_validate(const struct nft_ctx *ctx, return 0; } +static int nft_target_bridge_validate(const struct nft_ctx *ctx, + const struct nft_expr *expr) +{ + struct xt_target *target = expr->ops->data; + + /* Do not allow UNSPEC to stand-in for NFPROTO_BRIDGE + * targets: they are incompatible. ebtables targets return + * EBT_ACCEPT, DROP and so on which are not compatible with + * NF_ACCEPT, NF_DROP and so on. + */ + if (target->family != NFPROTO_BRIDGE) + return -ENOENT; + + return nft_target_validate(ctx, expr); +} + static void __nft_match_eval(const struct nft_expr *expr, struct nft_regs *regs, const struct nft_pktinfo *pkt, @@ -932,13 +948,15 @@ nft_target_select_ops(const struct nft_ctx *ctx, ops->init = nft_target_init; ops->destroy = nft_target_destroy; ops->dump = nft_target_dump; - ops->validate = nft_target_validate; ops->data = target; - if (family == NFPROTO_BRIDGE) + if (family == NFPROTO_BRIDGE) { ops->eval = nft_target_eval_bridge; - else + ops->validate = nft_target_bridge_validate; + } else { ops->eval = nft_target_eval_xt; + ops->validate = nft_target_validate; + } return ops; err: -- 2.47.3