Article View: linux.kernel.netdev
Article #10860[PATCH net 09/13] netfilter: x_tables: check target name before accessing verdict
From: Pablo Neira Ayuso
Date: Wed, 04 Nov 2026 09:02
Date: Wed, 04 Nov 2026 09:02
109 lines
11800 bytes
11800 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:
<20261104090224.750548-10-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-356304-linux-kernel-netdev=dewy.ruReferences:
<20261104090224.750548-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-356304-linux-kernel-netdev=dewy.ru From: pablo@netfilter.org (Pablo Neira Ayuso) Newsgroups: linux.kernel.netdev Subject: [PATCH net 09/13] netfilter: x_tables: check target name before accessing verdict Date: Wed, 4 Nov 2026 10:02:20 +0100 Organization: Usenet Network Message-ID: <20261104090224.750548-10-pablo@netfilter.org> References: <20261104090224.750548-1-pablo@netfilter.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3357387"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:vZQB+5Lslfy9zniaQjYKIUlkiJU= sha256:k7rupruuT7+bPG7oqp3X4Xhl0/K/sdwQJbLKesT8qv8= sha1:UrO3luIFiHTLreNM31ZtvB+FXU4= sha256:UjRSX57K65Qkn5OAye9xCFOrbHoI4+g85JbsNLLYYEI= 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 66679112B40; Wed, 4 Nov 2026 12:04:26 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.15 X-Spam-Status: No, score=-3.15 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, URIBL_BLOCKED=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 027n5sJE8QDz; Wed, 4 Nov 2026 12:04:24 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-356304-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 15921112B2D; Wed, 4 Nov 2026 12:04:15 +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 630BA6079C7; Wed, 4 Nov 2026 09:03:19 +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=1793782973; b=ud61xqn3cb0oXu+Ys2hDxnXttX9Wdlu4JsDgYkV+fdZz76udTbMbEBdv//lsv5CS3Tnn gvO+zTd5xKpY+zqhMKQn4Cy0X6PawDbFUaJqFZDU3zy2q19B8LeFxgyqlnldxhW/u10QG zA2pM6QQrgveEnLmvUaa5lR0x/ed3xxhHHTXtYlbjNK4u0keWKsx9aRAgVXIFUiZD/n9R A7sBxYPvp9uc3klvFLvumqbwprVqH6Ls/f78N9iz0IwaoaJTDcQvHI5IRkzHp3YSlm1Po 9i2e42lZ2QJJk7OrJDgWkk5waKI3uBX8IXrCn/ZAskHWmeUT2ynaGxQ9DuFQ+3S8ltw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793782973; 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=Ch7pWsA7fvAO9LspKri2UmVDqqaVWT4z2CTgR1PEK0Ru5msqww7B34PbuvG00He24nyy gQsqK55zkcaXrUCzNbVZ4M4EmvqWYbaq+c/GfhcuC2sJlp21swUKVcWLlt8zQYUJOqFgV r6PP8KGXKbUSdKI4J3BuHgMR96uoXxYKoFkmTfcRp3Stu59iLt10Dkqs8CzDQZaUQLEtb p43gda5ZG306suako0RGna+1Rirg/SOOdptYFfBBu0z6FDLko+7v6attzXTRDpqfXH6av MRITSOuIx2hmLR9IsIZd48lpAGKYoF8R8p28ojpjkwURfXd1Z/yOWzl0TOT2f1PwQHA== 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="P7mUy/cm"; 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 B9318606A339; Wed, 4 Nov 2026 09:02:53 +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=P7mUy/cm 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=1793782966; b=Rd2gEEazv1HAyPWhSYVqs0Q0jh0fb6100vYKY2vDfg3oNn7aWLLU0tlo8/d+dJowf+iM epG1wDoGTVmfVBD1LR8yYibXHiH4kjneXoCBkF81go2X0MFaQoLw0jUWil8e/0USvczND LglRUuHcJva86jQFnhQ9BviXCT6ADw45Rn9oku4dE8ECy5C8pL7ukNRytyXabllyIsArg yRSg+N8qogsltgXmjkricYgKil0ba3I7XP+nkTLZLiuEQwo5Sy2Z9Z541iDnmPVEjKT/b GQhxw4h2XlRRDOPJ1m9VTUl99NRDujlL3gmEb2vbSxXHtay7/BOFyxvqdApx3sOcvkw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793782966; 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=UxLn6ujMlv3SvPt2QPlxTLRysW2DLeRGop9YICZjQNWQExgkg5BDv4C/xANxNSpLIBCL qiUw27QAgiGeVIlM/YnDfoxyKH5j8BxBJAnMf2wSkBbCYwQM66ol5Iwy6gfefu1eC0yuo szZNXrJU+uKbgSk4UC25kK63/AoayWieA/BYAFbsnuIPnPU7sFo/2yt1maE0qBaeGQDkI VRFf4zrgBK5Nf5YtXNmRue+trrXnYBbPt8X00OgO75sQLwtZc9IC8k2evk9SCCZ93zMwj 0WvPEh3tsB0NSMl4lMkfmjD+3I8pR4zvqQHgp8zsX+Xqu3DstTBdUGex2i/B3y3NNAQ== 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="P7mUy/cm"; 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 7345C606D819; Wed, 4 Nov 2026 09:02:46 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7345C606D819 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=1793782964; bh=XClvt/H6YMd9+Exyu1R4Oy60MLFqQ2fw95DTYxl2feU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P7mUy/cmJf1PiTJZs6KLC4gLCNsW0jTI/w5qbv59JTALAq3CLqfjil5dmpX6ee3ch 0cwM2HNGIqG7RX7PjKGdkwc+BShrvMKXBFZJ3WIvAnT6OJA4EydQQZspqcQWECVGOd EpSuxBKuWCnZVA0HgukkU2PAuWOnqxnw44Ga+HWL76bkAvR7kOOfDLZ1OnM9UJthmj gfAIFYB+Ak1N7aj6bPfQVaNTy4qKyQNSpCi4gHZEaSaRj5KqK2COejodrt/GIvxG91 hde5N7CYRIbVOhwYZTztTBWd1m8iARB+dacmL0NPB5W8x8E5h+8ROERz2ybKzYSfcq kHo3GEYZIm9rQ== X-Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 66E916008A; Wed, 4 Nov 2026 10:02:44 +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: <20261104090224.750548-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