From patchwork Fri Mar 1 00:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 1906499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=netfilter-devel+bounces-1130-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tm8Y70ltvz23l2 for ; Fri, 1 Mar 2024 11:46:34 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CB67B1C20E3B for ; Fri, 1 Mar 2024 00:46:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C62BAC158; Fri, 1 Mar 2024 00:46:28 +0000 (UTC) X-Original-To: netfilter-devel@vger.kernel.org Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43E25C134 for ; Fri, 1 Mar 2024 00:46:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.188.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709253988; cv=none; b=YD+RBXOYBhLehT9HALP8FXOiST0K3u2u781oSNxNZi5SwHisSelWGg5WGEy09UTq/ecAS4fYMDdpK06Jq0ZxkxI0PjvpRJqb30gxwtSgLJQQi6Dzqt63lc2GK0/p9bciWh0QIzdtFjsPxcmB8kO6NAk7sNg6DBglh3D6R72FqQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709253988; c=relaxed/simple; bh=JG65XC+0DX0STNIR9JvvZ5Gej8ckUjrZ04ai089mC2g=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=hToETpyn2fKCh7a+60UM2PTPtKGbifXK3KuRX/lBXW1ZDWYWWI2jQYQCM6PplibT8/BSb9lCz4Lk20a4Cam0j3SywRtIQzYyzt7jmzKjdHbkIu6Ro/rNFRjLu9TYcNQuW/FmXxRodC8RQ118rXrv98pS9BFUTDvw7KDra9lVrYI= 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; arc=none smtp.client-ip=217.70.188.207 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 From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Subject: [PATCH nf 1/2] netfilter: nf_tables: disallow anonymous set with NFT_SET_{TIMEOUT,EVAL} flags Date: Fri, 1 Mar 2024 01:46:08 +0100 Message-Id: <20240301004609.10237-1-pablo@netfilter.org> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Anonymous sets cannot be used neither with timeout nor with the dynamic flag to be populated from packet path. Reject these combinations. Fixes: 761da2935d6e ("netfilter: nf_tables: add set timeout API support") Reported-by: lonial con Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 7e938c7397dd..70f90e7d108c 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -5001,6 +5001,9 @@ static int nf_tables_newset(struct sk_buff *skb, const struct nfnl_info *info, if ((flags & (NFT_SET_EVAL | NFT_SET_OBJECT)) == (NFT_SET_EVAL | NFT_SET_OBJECT)) return -EOPNOTSUPP; + if ((flags & NFT_SET_ANONYMOUS) && + (flags & (NFT_SET_TIMEOUT | NFT_SET_EVAL))) + return -EOPNOTSUPP; } desc.dtype = 0; From patchwork Fri Mar 1 00:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 1906500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=netfilter-devel+bounces-1131-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tm8Y923LRz23l2 for ; Fri, 1 Mar 2024 11:46:37 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5C299283AB7 for ; Fri, 1 Mar 2024 00:46:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B8A0C2C2; Fri, 1 Mar 2024 00:46:30 +0000 (UTC) X-Original-To: netfilter-devel@vger.kernel.org Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 859AAC135 for ; Fri, 1 Mar 2024 00:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.188.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709253989; cv=none; b=U1rBIrD7rs7gvMAzhKIhS7cRS9UxNzxqmzhSxdRYMhIyM+bLWiIOqicRdxHkX3i0gpb/RiVA9Abv18QV7L5epJiDYUWThA70keIPAT2SjuCPVdGgRCMf0xemAxQNk76U6Yu9jKJXyo/zN9WyO/ApEdKVnQMeXpi7NMw81Pnm37w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709253989; c=relaxed/simple; bh=gZpgL/aBm4bAND9Geq7IUuGejDIm2+bAlMhjHYaPCGc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g+HkxZz8IE0YlLhiXVNwb8fUN8QRHc9cM/vLyRsZSX/aqd7qBe7gxfxRkFRhhN99nBBav4VfI32hxaY0GAslNU1JnMhhhim6lD+hva2E1J3rvGMREgt7xp5qJjtgOjx5ea3QrHAIrmGKLjiQN1VFAVj83MsxST9t1wgxHnEgpXc= 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; arc=none smtp.client-ip=217.70.188.207 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 From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Subject: [PATCH nf 2/2] netfilter: nf_tables: reject constant set with timeout Date: Fri, 1 Mar 2024 01:46:09 +0100 Message-Id: <20240301004609.10237-2-pablo@netfilter.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240301004609.10237-1-pablo@netfilter.org> References: <20240301004609.10237-1-pablo@netfilter.org> Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This set combination is weird: it allows for elements to be added/deleted, but once bound to the rule it cannot be updated anymore. Eventually, all elements expire, leading to an empty set which cannot be updated anymore. Reject this flags combination. Fixes: 761da2935d6e ("netfilter: nf_tables: add set timeout API support") Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 70f90e7d108c..9e04fbb2065d 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -5004,6 +5004,9 @@ static int nf_tables_newset(struct sk_buff *skb, const struct nfnl_info *info, if ((flags & NFT_SET_ANONYMOUS) && (flags & (NFT_SET_TIMEOUT | NFT_SET_EVAL))) return -EOPNOTSUPP; + if ((flags & (NFT_SET_CONSTANT | NFT_SET_TIMEOUT)) == + (NFT_SET_CONSTANT | NFT_SET_TIMEOUT)) + return -EOPNOTSUPP; } desc.dtype = 0;