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 CE9C944DB64; Tue, 16 Jun 2026 16:26:29 +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=1781627190; cv=none; b=dW70gVdC0ZB6T+B1HGpUTvHz1uTzFiH2pEDURG+xt7vKgBLOFCAhs/DiX3pVaSy5xbcw+mTOlLurdhWtkGLHhYy1MMrFvh0aJz/Sb3/MvrkwiMhrAgw0dDX1mgGfnzMWkhpbpseczxbtgJi/gis+aiKXkLjlCm4Z4vOQTheQs/A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781627190; c=relaxed/simple; bh=CRrARbBAgDBUJ+jpTQGq8Pftsw50jZiUThmwtFbNxXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OxQL6zqhNkHkxC+wE/GJWCrNSwej5r7hABjGpLlIrz89FyomnY3MDfdjPii2/hNh7E6pwpI39IopSovtJ7YJ/Dac+idpMbTxR97GS4SpP/65PC4DcnysBqMovSW8hRmENN22nknFdBbptQZI2DMbPoAeaVNToc/pvqJtRw1rytM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vlkB7d/K; 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="vlkB7d/K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B3F11F00A3A; Tue, 16 Jun 2026 16:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781627189; bh=g2bK+QevskIT/6ha3wF7LDP/sMRJ0kECTVr0CvfU2k0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vlkB7d/Kkml2izVPh/DQ2Mlwrd2k34alFGYOiney5l53QhQXRlWQdvt+vt0cmNJ2k aX5Zpl1WR5sh+TeGhSHplGmPmCiAb695gu3q1veYGFPtJvpIY1F2KwYI896UMModNu PjrS44eldZLtn9gTVrF6+vEWj9X/2c95QC3H55mo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jian Zhou , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.12 101/261] netfilter: nft_exthdr: fix register tracking for F_PRESENT flag Date: Tue, 16 Jun 2026 20:28:59 +0530 Message-ID: <20260616145049.714552536@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145044.869532709@linuxfoundation.org> References: <20260616145044.869532709@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: Florian Westphal [ Upstream commit 772cecf198da732faebb5dcfc46d66a505be8495 ] nft_exthdr_init() passes user-controlled priv->len to nft_parse_register_store(), which marks that many bytes in the register bitmap as initialized. However, when NFT_EXTHDR_F_PRESENT is set, the eval paths write only 1 byte (nft_reg_store8) or 4 bytes (*dest = 0 on TCP/DCCP error path). When len > 4, registers beyond the first are never written, retaining uninitialized stack data from nft_regs. Bail out if userspace requests too much data when F_PRESENT is set. Reported-by: Ji'an Zhou Fixes: c078ca3b0c5b ("netfilter: nft_exthdr: Add support for existence check") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_exthdr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c index c74012c9912554..1fc2a948d00afc 100644 --- a/net/netfilter/nft_exthdr.c +++ b/net/netfilter/nft_exthdr.c @@ -530,6 +530,9 @@ static int nft_exthdr_init(const struct nft_ctx *ctx, return err; } + if ((flags & NFT_EXTHDR_F_PRESENT) && len != 1) + return -EINVAL; + priv->type = nla_get_u8(tb[NFTA_EXTHDR_TYPE]); priv->offset = offset; priv->len = len; -- 2.53.0