🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10411

[PATCH net 11/15] netfilter: x_tables: check target name before accessing verdict

#10411
From: Pablo Neira Ayuso
Date: Tue, 03 Nov 2026 14:03
109 lines
11777 bytes
From: Fernando Fernandez Mancera <fmancera@suse.de>

Non-standard targets may contain only struct xt_entry_target.
mark_source_chains() nevertheless reads the target as an
xt_standard_target before checking its name, potentially reading four
bytes beyond a header-only target.

Check that the target is standard before reading its verdict.
Non-standard targets remain handled as fallthrough rules.

See the following KASAN trace:

BUG: KASAN: slab-out-of-bounds in translate_table+0x1660/0x1a40 [ip6_tables]
Read of size 4 at addr ffff88800ed56ff8 by task rep/432

Call Trace:
 kasan_report+0xfa/0x120
 translate_table+0x1660/0x1a40 [ip6_tables]
 do_ip6t_set_ctl+0x667/0xa76 [ip6_tables]
 nf_setsockopt+0x77/0xd0
 do_sock_setsockopt+0x118/0x490
 __sys_setsockopt+0xe4/0x160
 __x64_sys_setsockopt+0xbd/0x190
 do_syscall_64+0xde/0x4f0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Allocated by task 432:
 kasan_save_stack+0x2f/0x50
 __kasan_kmalloc+0x7f/0x90
 __kvmalloc_node_noprof+0x1b1/0x5c0
 xt_alloc_table_info+0x3c/0xa0
 do_ip6t_set_ctl+0x5ee/0xa76 [ip6_tables]
 nf_setsockopt+0x77/0xd0
 do_sock_setsockopt+0x118/0x490
 __sys_setsockopt+0xe4/0x160
 __x64_sys_setsockopt+0xbd/0x190
 do_syscall_64+0xde/0x4f0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: VEGA <vega@nebusec.ai>
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/ipv4/netfilter/arp_tables.c | 5 +++--
 net/ipv4/netfilter/ip_tables.c  | 5 +++--
 net/ipv6/netfilter/ip6_tables.c | 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index cf747e1e17a3..7ff3d1f0ffd4 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -371,11 +371,12 @@ static int mark_source_chains(const struct xt_table_info *newinfo,
 				e->counters.pcnt = pos;
 				pos += size;
 			} else {
-				int newpos = t->verdict;
+				int newpos;
 
 				if (strcmp(t->target.u.user.name,
 					   XT_STANDARD_TARGET) == 0 &&
-				    newpos >= 0) {
+				    t->verdict >= 0) {
+					newpos = t->verdict;
 					/* This a jump; chase it. */
 					if (!xt_find_jump_offset(offsets, newpos,
 								 newinfo->number))
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 809441cedced..b302bd77180a 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -422,11 +422,12 @@ mark_source_chains(const struct xt_table_info *newinfo,
 				e->counters.pcnt = pos;
 				pos += size;
 			} else {
-				int newpos = t->verdict;
+				int newpos;
 
 				if (strcmp(t->target.u.user.name,
 					   XT_STANDARD_TARGET) == 0 &&
-				    newpos >= 0) {
+				    t->verdict >= 0) {
+					newpos = t->verdict;
 					/* This a jump; chase it. */
 					if (!xt_find_jump_offset(offsets, newpos,
 								 newinfo->number))
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 313c4aac377a..010baaa60665 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -440,11 +440,12 @@ mark_source_chains(const struct xt_table_info *newinfo,
 				e->counters.pcnt = pos;
 				pos += size;
 			} else {
-				int newpos = t->verdict;
+				int newpos;
 
 				if (strcmp(t->target.u.user.name,
 					   XT_STANDARD_TARGET) == 0 &&
-				    newpos >= 0) {
+				    t->verdict >= 0) {
+					newpos = t->verdict;
 					/* This a jump; chase it. */
 					if (!xt_find_jump_offset(offsets, newpos,
 								 newinfo->number))
-- 
2.47.3
Technical Details
Message-ID: <20261103140308.591690-13-pablo@netfilter.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355692-linux-kernel-netdev=dewy.ru
References: <20261103140308.591690-1-pablo@netfilter.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355692-linux-kernel-netdev=dewy.ru
From: pablo@netfilter.org (Pablo Neira Ayuso)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 11/15] netfilter: x_tables: check target name before accessing verdict
Date: Tue,  3 Nov 2026 15:03:04 +0100
Organization: Usenet Network
Message-ID: <20261103140308.591690-13-pablo@netfilter.org>
References: <20261103140308.591690-1-pablo@netfilter.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3183423"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:M2KsCdZ/gKLArvm7maeh4xkOF08= sha256:Y9DD1zeNjoQcQEQLiGpvSH3YhXVSMNHlmXmKqefYBxg=
	sha1:5LoezuO8+amoRy8xZ6HEG2AgZ/c= sha256:Ylgf7ywQfrzEqDxXE6CH1Cd6ih57eIf9HFqzbc7x9vE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 49E111128CD; Tue,  3 Nov 2026 17:13:52 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=netfilter.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id tFTg-thODHNQ;
	Tue,  3 Nov 2026 17:13:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-355692-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 6F3D51128BA; Tue,  3 Nov 2026 17:13:41 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id BE0C560E26B; Tue,  3 Nov 2026 14:06:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1793714620;
	b=2DWHYQ6emNVPRUNwBLh6cQTxB4V8sZ8QzozQba6SWK8zO31FPXsqemOBp2PpeNa84kYv
	 CGTUneOAL/S640NUfnIxCYuj6ud8uJdhxyR6cw4AXkdwYOdsbd+pM9fGOHOizQc4dt++6
	 9xoaa4Bp7sb5zwbR++O6Hw3nk1dW9putfCm+65INhhvu43ZXWhZfivLnXzkChzWMZAF6b
	 nJNFT7Q5aI4oGJFZQaVQsBQpkk9p2GQ9ziIUPIvv9+vzl1uJmz7ongpaEqHChEDUQBE2m
	 /k3WwvSVKZRMolCSb8v9MtkOK6qbuhNlWt4418kGOAQ5rNGE3b/5rFGQbutA3bi2Bdw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793714620;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To:
	 Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=XClvt/H6YMd9+Exyu1R4Oy60MLFqQ2fw95DTYxl2feU=;
	b=SabJbOTAR5WBbH3I/LXRBTzeufVVk9Le1CY6i9YRTc6bpI/MrU0Z7Axs1G3I3+dyRWw3
	 7CKjiy15g+4x0IjeMYjGE2DolAEhgeJf/O0TRdoHlc44OpYfH163P51hgti3NmjFpggj9
	 Ht2kdp/Q8CLhRkKUry6tnicFiEPY+Np9XYsrG9D8jsmh6fNRLtMhFZ/n841DbCGQSna5n
	 YNhqYXHfUcNwDwpEhJ92IUv4+K1PuGazU/z6MH2XvTG/N1UH32EGQGvNQgaCFawCz4lnT
	 1bcYzrdEmcP4xgf6eYT5WWAuMnfsImFntA5dn/VsRaVSuf0dVs8znp5ZRwzrGxV2oBg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=JTyHBhbv;
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	arc=fail smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D24660A6F78;
	Tue,  3 Nov 2026 14:03:40 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=JTyHBhbv
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793714614;
	b=E1y4RjLHH533X+NKu4UeyyWdud+gOV/Jyald+rmiUEkP8N4JZpmJQ7w60TVSvUj9xoIo
	 2MhKbvSmvc7aVMAQYuWypOX2EmHINvhlI8SFlPu0Gzq/8CSO6OhVslmVhtbf7s3xIDB3J
	 q4a1tuGuArVZTgL7O1nYMSM7lNSsHdoasc7Th2+kwkLZWwzygM8hiSfsTCKWvCXIVVJMo
	 pNFJGcujxShrnwluzad1MwwMI5ms2q4vp/EsGku3NB3PKebi1Ler4wlLwAEwWxS0zvdIl
	 PkF2FQyIriQ4WVDm4ZkOmeYf+RkaTISkoo8c6a8xWkstZUKBKQ2xSlhyhdOTTAdyK/A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793714614;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:X-Spam-Status:X-Spam-Checker-Version;
	bh=XClvt/H6YMd9+Exyu1R4Oy60MLFqQ2fw95DTYxl2feU=;
	b=dGmqmKCkUxhe9oiu3UwsKsNgLpnPNnuNjxvXg92zCRfrQ4eHvsKC7eZ30kF2taGeiT6H
	 sTKU4KjhrBC1r+Ch6blhmmz4cQUKRW89R72+7kbQ80eUIS7xh2fJtt368B2MK+qT6NgYA
	 4CYl24soMhreAGtGSRv1FLBZphCd/Ui9IuB8rIT0FObQ3spizsBpUinp3l43JIzkjMbpg
	 80i6F3i2mxzvIvEci8Nq+naufbU/PvCyBB0eW/KL0rDbA3h6aAQo7I7k3PV2yvLKtKa8Q
	 D3rjcWjGAsK9w4i+3yHNCD2PUzShPWpVDgsrYPZNXDDZuyrXZ14DT5JJvqbE7y/0b9g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=JTyHBhbv;
	arc=none smtp.remote-ip=217.70.190.124
X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 275056083602;
	Tue,  3 Nov 2026 14:03:34 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 275056083602
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org;
	s=2025; t=1793714612;
	bh=XClvt/H6YMd9+Exyu1R4Oy60MLFqQ2fw95DTYxl2feU=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=JTyHBhbvW5sKNqnrRgo/Yoojp2d67tmLqGe1mmfqHtX9kkbuuAZqheIcz9Aj5m+Zl
	 x7s3Tw1E20Yc01p8TKW+nS8c/VDGKQ0AbB7A3ZmkaTh5RdnU3rYIE5WB/XYXTgsAzh
	 QIJL3+zWqgypRlnaXUTUUKNbOSA9H2+6DlE2QU1eZ2jXVLJJ2isz1GtFOTafP7x+3X
	 bFR6oOItle9d6sY8/WWdTCOjlv0WmgQ4dUhMrPpoL0KwaVRvdQt9MLtZzlfZjpAian
	 kpqb7tv66yz6Zu/U9GS0Y3iTB06GbZMBBlWRl50EIjKWz0ypheIy/g0sjNIWpw0R1P
	 PvtKM0MIrEKQw==
X-Received: from localhost.localdomain (mail-agni [217.70.190.124])
	by mail.netfilter.org (Postfix) with ESMTPSA id AF4B560085;
	Tue,  3 Nov 2026 15:03:31 +0100 (CET)
X-Cc: davem@davemloft.net,
	netdev@vger.kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	edumazet@kernel.org,
	horms@kernel.org,
	fw@strlen.de,
	ja@ssi.bg
X-Mailer: git-send-email 2.47.3
X-In-Reply-To: <20261103140308.591690-1-pablo@netfilter.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list