Article View: linux.kernel.netdev
Article #9415[PATCH net 11/15] netfilter: x_tables: check target name before accessing verdict
From: Pablo Neira Ayuso
Date: Mon, 02 Nov 2026 00:56
Date: Mon, 02 Nov 2026 00:56
109 lines
11796 bytes
11796 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:
<20261102005654.532438-12-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-354400-linux-kernel-netdev=dewy.ruReferences:
<20261102005654.532438-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-354400-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: Mon, 2 Nov 2026 01:56:50 +0100 Organization: Usenet Network Message-ID: <20261102005654.532438-12-pablo@netfilter.org> References: <20261102005654.532438-1-pablo@netfilter.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2813174"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:DxLx5PsJ+SWj0ahJfYBZaoU1qEw= sha256:fntifUYU5kOyqvF8vsmEw8jc+hAHJDdwS449VlQ2ehg= sha1:Wr4pbPlGD31D7Z9qigttAv/reDw= sha256:M8r4iTPBX2f/brsy2+5CG9QFCMjlI/Il4DfxCyz/nwI= 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 D57961123E2; Mon, 2 Nov 2026 04:00:21 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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 En3XKBnfpQeC; Mon, 2 Nov 2026 04:00:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-354400-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 779531123C8; Mon, 2 Nov 2026 04:00:11 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id C9AE62D14F; Mon, 2 Nov 2026 00:57:32 +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=1793581044; b=T2YIiWC2qW/f8F0OdKiLVxhUMK/HwdAp/RutJrYwR+fTgba7JZg9QqaFvY7F8XdNcif8 uuvCo5hez+TNicxfSa2Inb42jrcpa2IOkHR9r1oyK5lKY23GvkmAZ8Wt3FzDmma+dDIol 203EFA6xfC3l8R1rlHNrlpqJfphxARkdeycESqsm4fSWkkBzGwQVnR8Od14KuT0iDxgVK Ut3SiatXlE6BZEXltNst/6etTNR8SSY7gX5rj1V03KOORupNkh52V/E8xAyU4Mqze2iUx 33u18fPkLdWnMRdfPNJ8h9GNqDodQfJCKb1GJ2hDL77OV4BjL0uHjMK2BzM0HaydWDg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793581044; 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=z5B3yfifkacPn25VqaqCaDGlH2MOrJp0KFyg7UrsHJ6zpW0Z7U09Ho2IMkRd96LBVPGk Do9sMGYiZE3++N5iAJSxagOWqMkGLaY52qiZsDUuGB5irzj/2oAJJvU6zbbfFZSH/+d2P Y+Gsa7bf0fpVSElpGbvjE4/YVj9i0Ns/LFF3I+0xcqiZLSk08UoulgaR1CwwkvhN1aK/B 89gyazPwSTm2Dr/Apki+yNjopOFNR5mHpL+t8dy+pVv1JxP+qe27KmqUrVhtatgeYdu64 uJIg7aZVVj5YWjq96x0Zyhp+9stPJn0QIFX+4oe6YiavRgfVgEK2i0ENXGsrA24akgQ== 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=bY4IxbW+; 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 D5A22606A32C; Mon, 2 Nov 2026 00:57:24 +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=bY4IxbW+ 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=1793581044; b=vZqYEJ9eUJyWaEiyiE0fL6j6hVbF1VxUAV8YKBI0/M3jK8tu8PC/5CDSNNB7tNjbGCPf hIM0Ns6zIQJK67ZtCpREJKxgEXx96Mif67PegTfca7EUrTdQRGnRc0t6e7lCi6xLRFZ7x c0f6cD1ZWFpTfz5FxTnt3yHzaVZDxk3ZBSRlAFn6cHn1Wi3gChfdopXwlX+y98Ev4ZlA1 pm6yx9kJlLGlwlfyN4S3UpI8+2oQjd4cgmxwHU0NvIOQ4FBYDP9WP4f52nn007AhZ2Yn/ 8mFTGSYRkUbN9GSjjYMJX/+t9PC9Yi3Vq3pk0g5by1yfvcXdHegNNznXgPL2v2CltNA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793581044; 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=D64ZGiaODWK5DaYyM0ygW9nMGgtZ1AV+965+a5+5vaK1EXkZBfwjm5v5OQ5PSg6WySn1 4peWdjWRm2mYomfcUI8QwKHt0NU0wb8ZRQvcijFPhC8ZLvFb+ae913JOGyB5eGD791GZy e3GWvFPXaDWW5+tiRRLEYi1sF+1GNpaZn4It2v4tlgMqeB9Ng8QN5+ryuYauPwOYOqg6z hPthg/2okk/dfK+a6oR86WJiv+JOXpDmcZGsmrHTG6UE9ijuq2qlepU2MqvUqyktbGT2c L/ijB1mMz5O7xCnQh7lwdg89baiepW0CXo8AXd5qic+ZYQucgKvfbJbffCAgtk2lTUQ== 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=bY4IxbW+; 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 807FD60A2613; Mon, 2 Nov 2026 00:57:23 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 807FD60A2613 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=1793581041; bh=XClvt/H6YMd9+Exyu1R4Oy60MLFqQ2fw95DTYxl2feU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bY4IxbW+3eQJqmiZ0pMUPXI8fl0ARrX8V3vZLUygczqzIXSikYSIePZ1lRnCDh4cB 5BqsI61zlCm5So30T3H+XFMedQRsuUi1w+6iWNmu/vfZcLbfwJPSkLqw7Le7pU8EBA h5Jgx2lcz4t7f3BED7xnAnvfgeACM1JszqL50/0huQUSVbd0mxd9vbfsxnY1lR3xqj Wi0WTZTudyO7X/YBuSr8bt53/wjDUML5JlEh7zhVX4edEduw8X0OwNHuwfQbBMJU7H C6TQXPTGmURlFbWhop3pTxKJFgqXObrSXkl7vukeSkmjLNN5OUJHEpul62nfahqbRc A9IXPKv8szg/A== X-Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 43C806005D; Mon, 2 Nov 2026 01:57:21 +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: <20261102005654.532438-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