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 59865328610; Tue, 16 Jun 2026 17:03:35 +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=1781629416; cv=none; b=I24G9LJQGFfZ1iFve8sp6KxUq/JPQxpQJxVJtWBkxMOMFfkurZTTAoO4tAbvnJTcnYeYl5EKboelE6kNHg8Qmvs2KHA+uNm2sKZytR4cx1iBQZC7VAu7wce4jjQk8R02una9Q+EjE6fNPg6jZpfz6YhGN9IX1nZk7Yf7u2iy+oI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781629416; c=relaxed/simple; bh=tvZjCx93KAg992l8Wdnj0ra/p7YWxw6l6Jh1NTcxsRg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=txq3BZ8AtpIV3D9lWni0ps33ClFVo/CBUt4v80v4U5PckVNi5IHmI7+eou9eQKjijVAGffUJQ+TGBh53PIbL6mItmTX6/A0Xq5FKvlwQ/aQqI1+io3Mv0dA5dBSytChkR5+27ejWpOrbIdu9lw1yjW8BfY8sn66vf7rYeITkeE0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kinchj4u; 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="kinchj4u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 695BC1F00A3A; Tue, 16 Jun 2026 17:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781629415; bh=eF925jAxu4RhPId/Z7sfiGUPfLP33qu+GqyApxn53wQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kinchj4uN0VJ6KbDTiaI02IbO/mEC2+2KAlUVYV5pXufmvfOfmEZyArU7P23aDwk+ IxkwiJzw87PzHVNmWCN316+ny6htAAhgUEQCdgsz4H8OsJm8CqQAas1o+U/RI+yulC KQ0GUv2mlgY93cCBGGaDtMqkuXzyGbys6KsRiw5I= 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.6 280/452] netfilter: nft_exthdr: fix register tracking for F_PRESENT flag Date: Tue, 16 Jun 2026 20:28:27 +0530 Message-ID: <20260616145132.338179138@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145117.796205997@linuxfoundation.org> References: <20260616145117.796205997@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.6-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 1d4c9632072c8d..cac46accf566b5 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