Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795624561; b=2bIFvHwBfbnwltMrA7z1iG/yrlY2vNwsv+6Wrf/pBGH4xqI+Wi6qEr5/9slivAlKt6w2 sVXpTX00yVWCM+3Jveg5HAXk5/9HXc4YpZYqjd9YLR27jO9019raDc0uIXXNJO8YVGKDq D22gYoYr4lA3e1ET/0eW3WgfMOD8p4JWr4uChkLrg3SE5PhJK6yO2b5lF6Z1ayLKFtZfN LyE7ezNabuXHQ+PV9aCLuGKBQUoei2H1QsbGltwhOxq8THsz4iyx0AR50TnTldkt4FMs2 iLN1jUFr9r5R53ytGWFWFbM0AdSSrF2Gf1Yh5zZP2UK/3o/Q4Li4pR47x64LOQSox8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795624561; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=cRc7BKdM0xOpRsrrKD8Hd++BI8XDPWrH57BfOF62pDU=; b=zo6rbYMYvLSoaqAsarVBxNhcgDxR1PGC1xSYSdyJvDqFHcr+JcqYdSDFhdWCgxKddUxA fh/ury8AAq9ntBGqE5yWY4V8UaMsgqbdtnEbVrLKl79jb12pCvp7sEajKyXs/GkGRGSPC aY8sW5gZ6hDvHRpK/5WuGNsmeUyd3HevDABxUNUT/yjYyDFn2Vvwx6uIT+YbsviZA84wM 0a2IwcrzNmtWMZ/RYm32QiiwVRysc8e5tsK3gLWiqIh9Ww3MbZL5g0m2lT4Th+EXFxh5r 7F8BKwhuXZHTrH9x8v7NqkwyILWxIpWKpSTY5uB0UPPpuZTjPbmeHiVRkxxoRoP0WmA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IGwZ6lPO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (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 55BB8606A33B; Wed, 25 Nov 2026 16:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IGwZ6lPO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96C1C1F000E0; Wed, 25 Nov 2026 16:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795624561; bh=cRc7BKdM0xOpRsrrKD8Hd++BI8XDPWrH57BfOF62pDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IGwZ6lPO6haWSFghGjT1NzwKK+UoalIVxDPqWbalFTDx7nCuWcaKe4bsU7SqRmzfs dZH9MlUZp2Eg1d+dUbKbRXKsUBXxRuLKCL7d2eROHb7Z3A3wLjQ+8Zd+av1uGgAb9j 0nbVPrI0ciSKlbORUPrVoE+dWdRTJYc871eY3Nyw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, VEGA , Fernando Fernandez Mancera , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.12 234/816] netfilter: x_tables: check target name before accessing verdict Date: Wed, 25 Nov 2026 15:29:42 +0100 Message-ID: <20261125143854.624211315@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143849.205329330@linuxfoundation.org> References: <20261125143849.205329330@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fernando Fernandez Mancera [ Upstream commit 364b200285bb2cc518e3c5efe6591951c05b8e01 ] 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 Signed-off-by: Fernando Fernandez Mancera Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- 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 c68ffde6d615d..9c7c53b22d1bd 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -372,11 +372,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 2411ef91d2962..4320f67df7baa 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 551d3ca1036d7..fb375ce7f916d 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.53.0