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 BFB904F55B6; Wed, 30 Sep 2026 16:54:08 +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=1790787249; cv=none; b=horxKiGocxku3exvGTAbL9L4FnA5vcXnP3Ypney5eYPSXtV54UM2sw04gSmQqlHSWVxcr6yOaIfKaiMxm8KJQNuyghjlqQp+KqmKWyLd47X5e5nJgLgqSytwIkZpuORIQvYtTAd5OfIf8U28FOzdq1fGhI4CwEq3sTRqZVEJxSs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790787249; c=relaxed/simple; bh=5/HMaimpps9liqW1c5gx4+TF5IR2lYe7sWy0vb/3mnE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oeu2wngxXsCucY3T0sYO7cQ8hC71lB2wpsxdC7DabGYtjkjcFSluuMO6Tw+UpNyo1B2EK1WIEzazUQkyMbMHBis5tLzcfKGpw92h2S4y4+Y1TYfwq2I0pvdz0aZTddqzKG0AXru0k1xxNflb1DzGHLMxw127WcRom8i+x1PfPvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=egvo0uB7; 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="egvo0uB7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 235A11F000FF; Wed, 30 Sep 2026 16:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790787248; bh=13RR91/BGUlP7BHuH2S4x4dB4/wAcwblpLKD/ikE1F8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=egvo0uB7hf9BHZoL3GvPSakLMcuVN88H1bxdE0ihJursEnBqAofZQIWGbznLPlekU naGn2O52NAaKYDtZRzHSuCEkIg7cD2VTL2wF1CVMI+I1/sd1634bEcrJJrWuYOYQAc Zx0UaBJUhkASDQLlyYDbkjTk/rVY973aD7dfkjmY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bernard Ladenthin , Jamal Hadi Salim , Jakub Kicinski , Sasha Levin Subject: [PATCH 7.2 165/457] net/sched: fix potential stack infoleak in em_text_dump() Date: Wed, 30 Sep 2026 17:24:30 +0200 Message-ID: <20260930152349.611763904@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152346.024115587@linuxfoundation.org> References: <20260930152346.024115587@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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bernard Ladenthin [ Upstream commit 9c572a83037a7dcd653ba3a9cc468c16b857d0c9 ] em_text_dump() allocates struct tcf_em_text on the stack without zeroing it. strscpy() writes the algorithm name and a NUL terminator into conf.algo[], leaving the remaining bytes uninitialised. nla_put_nohdr() then copies the full struct to the netlink response. KMSAN on Linux 7.2-rc6 reports two kernel-infoleak splats from this path, one triggered via "tc filter show" and one via a raw RTM_GETTFILTER dump: BUG: KMSAN: kernel-infoleak in _copy_to_iter+0x1c9/0x2620 nla_put_nohdr+0x83/0x130 em_text_dump+0x291/0x550 Local variable conf created at: em_text_dump+0x5d/0x550 Bytes 168-179 of 199 are uninitialized I am not certain whether this constitutes a real security problem in practice: the test was conducted in a controlled KMSAN environment and the leaked stack bytes may or may not carry sensitive data on actual production kernels. I am reporting it because KMSAN flagged it as a kernel-infoleak and the fix is straightforward. I can provide a userspace reproducer on request. The original code used strncpy() which zero-pads to the destination size. Commit b04202d6065c ("net/sched: replace strncpy with strscpy") replaced it with strscpy(), which does not pad, creating this condition. Zero-initialising the struct closes it. Fixes: b04202d6065c ("net/sched: replace strncpy with strscpy") Link: https://lore.kernel.org/netdev/20250327143733.187438-1-richard120310@gmail.com/ Assisted-by: Claude:claude-sonnet-4-6 [KMSAN] Signed-off-by: Bernard Ladenthin Acked-by: Jamal Hadi Salim Link: https://patch.msgid.link/20260918133953.12494-1-bernard.ladenthin@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/em_text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/em_text.c b/net/sched/em_text.c index 343f1aebeec2a..4132f8c3c5fc9 100644 --- a/net/sched/em_text.c +++ b/net/sched/em_text.c @@ -113,7 +113,7 @@ static void em_text_destroy(struct tcf_ematch *m) static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m) { struct text_match *tm = EM_TEXT_PRIV(m); - struct tcf_em_text conf; + struct tcf_em_text conf = {}; strscpy(conf.algo, tm->config->ops->name); conf.from_offset = tm->from_offset; -- 2.53.0