From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1B257404E; Sat, 17 Oct 2026 16:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792254704; cv=none; b=IkeEc2mMQQ70jO2Z+kkV4zLfQPpCbZ8nXRe7L1uzqfvt27V53pe7Ihk2sMmB6BAHWNlfyAvHLfgthEa44exrqZCviGKt+wn77cg33h4PSgZS9ivus6ebfo/cuZesMyTMt9aL5RGqlcjaImy6gHBkMZoAx30oy8gsXihCAnJDu0o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792254704; c=relaxed/simple; bh=c2IXWzvBN8g46VQJmYoqThXa/9BsTtNvs2hBl3U1MlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bRcxhKiE21g4x9b1gt/rA2URKDO05JsI91B5QYNW6kxFI59c2o7cnOqDsJ/RxRU3nP/vUkkKDyMtMKfNYhscpB9RIU3TsjSv5/BB5I31asaFcvLW1iT1ApcYza2XPhCJf0NOAnPKA8RdkH2YO6B4BUqzNeXNGkrFJJvVQXm8Uuc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=x8V763xl; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="x8V763xl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5A691F000C4; Sat, 17 Oct 2026 16:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792254703; bh=6uImR8M/yCLpEcjEyo9xib2ld1FiW/VZfkvSzlTyvnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=x8V763xlro9/G0Sl5xanOOJ9m0tD6xht4pKthThcM4TTwwyvdYZPIhfd7D6GJoef7 F1rJkMGtVg3CNpPn2UuaQRVFKkAYQJtBzkFR7xXuOjLZIKnYobn4vnikZpW6CsGFF9 EFH3HPkHvsnAEEq+lsmhAG3+g5FrC2QVyR+XHCLI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Carlier , Fernando Fernandez Mancera , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.12 534/869] netfilter: flowtable: avoid num_encaps underflow on bridge VLAN untag Date: Sat, 17 Oct 2026 17:56:15 +0200 Message-ID: <20261017160050.794914400@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160036.979869304@linuxfoundation.org> References: <20261017160036.979869304@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Carlier [ Upstream commit e052f920773b73be49eb4d8702a9f85de7464363 ] The DEV_PATH_BR_VLAN_UNTAG case post-decrements info->num_encaps inside WARN_ON_ONCE(). num_encaps is u8, so if it's already 0 the decrement still happens and wraps it to 255. The break only leaves the inner switch -- a later path entry can set info->indev back to a real device, and we end up returning with num_encaps == 255. nft_dev_forward_path() then walks info.encap[] (size 2) up to num_encaps, which means an OOB stack read and a bogus count copied into the route descriptor. Should only happen on a malformed bridge path stack, hence the WARN, but worth handling sanely. Move the decrement out of the WARN. [ While at this, remove the WARN_ON_ONCE since this can only happen with a buggy bridge path stack --pablo ]. Fixes: e990cef6516d ("netfilter: flowtable: add bridge vlan filtering support") Signed-off-by: David Carlier Reviewed-by: Fernando Fernandez Mancera Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_flow_offload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nft_flow_offload.c b/net/netfilter/nft_flow_offload.c index 4ddf3eb002259..99d3454f9e3b1 100644 --- a/net/netfilter/nft_flow_offload.c +++ b/net/netfilter/nft_flow_offload.c @@ -150,10 +150,11 @@ static void nft_dev_path_info(const struct net_device_path_stack *stack, info->num_encaps++; break; case DEV_PATH_BR_VLAN_UNTAG: - if (WARN_ON_ONCE(info->num_encaps-- == 0)) { + if (info->num_encaps == 0) { info->indev = NULL; break; } + info->num_encaps--; break; case DEV_PATH_BR_VLAN_KEEP: break; -- 2.53.0