From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796385927; b=YWodQk2PVoX1rKT00leIcK5jWpuHOB2LCTseli/8e9QEKkPMTprxtE7EBPqfltoIEEdp fzOvJ4E1WjQJHxbSZcHbuBg23M2pSFjeB/5ey6wyWNQQmdp2lzo8HOMMIYy2nmiWY9Q3f Nxa0RHUARqFkE6BfuHP8qoXnyS6255IgIEKYcfgdkdDeqwp4BE69/Co7FovCFBwf6wEVV kxwpfGMLpO3TkrrbD4OSXwrH/V/EL3L9zv/7S+Cph/XF+3U7+QVjWhEsFPJDEdyW5tnS4 BtKURyKvIaiPwwepzWnck5FGFduPM3zxbV9GKSG6S6yCIJ3Ek/vBzsICZqkAxMJEl0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385927; 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=pI9MMsLEIsTbNueTRPHqURPWjmElMpqaOuVDYzHrdDY=; b=uccgVCe6BBNGp6GhTZBuofM27+Kyxi3ejqU3/1nKjTt4xXPa89hSL9j1SNBZrPJrczDA +CSertojy2ocinpa7gkP42tueoYmxp53KMzX9J7edCGlR+RpQs5b/Mn9PZ6BAdKOGbmX7 sDOis08S0ddiWOfUNCiEyKA/xP8xVi2hveLYFz0pPAOpYubIB02bqvfERBGksiWFuO0aq XAsu9hbNVjSwGGwF+ZTE40ySgMbXH+rC+UdOvTprhEFlgP2SzsJw1ktJiRd98yIuNazmi nessqS6HT8G+mpLF3Dh00461Q7l9M+HZldllhbpOt6nRSADkvI5vxPZUxAjYADRoo1A== 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=is2tN7Vz; 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 AF2FE606A32F; Fri, 4 Dec 2026 12:05:27 +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=is2tN7Vz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26A611F000CE; Fri, 4 Dec 2026 12:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385927; bh=pI9MMsLEIsTbNueTRPHqURPWjmElMpqaOuVDYzHrdDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=is2tN7Vz6ykr4Cjbmdlm5nIIGUZOLiWkDG2wG/c+NaohAUWaPBO3pPge0U7eLi5kS cAoKNRAJagKsK6lodprmdJtM3EafxlVe+J4Fkn9JNImrGU+gVCbULpktrqhHLgV2o4 E8+WxX8/j/yomVkUGvv7Xj0dEj+d5bcCpS6me2Uc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Masami Hiramatsu (Google)" , Sasha Levin Subject: [PATCH 6.6 0750/1167] tracing/probes: Fix missing BTF kind checks in char pointer/array helpers Date: Fri, 4 Dec 2026 19:02:57 +0900 Message-ID: <20261204100721.604243481@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Masami Hiramatsu (Google) [ Upstream commit c1e2c63e65421068566db3dde44dfd4fe7adb46d ] In struct btf_type, the type ID and byte size share a union, and only BTF_KIND_INT types are followed by a 32-bit integer encoding word. Because btf_type_is_char_ptr() and btf_type_is_char_array() do not verify that the outer type is BTF_KIND_PTR or that the resolved element type is a non-NULL BTF_KIND_INT before inspecting it, non-pointer BTF types can have their byte size misinterpreted as a BTF type ID, and arrays of non-integer types read out-of-bounds or misinterpret trailing BTF metadata as BTF_INT_* encoding bits. Validate the BTF type kinds and NULL pointers before reading inner type metadata in both helpers. Link: https://lore.kernel.org/all/179455851632.403392.258264246782960594.stgit@devnote2/ Fixes: 27973e5c64b9 ("tracing/probes: Add string type check with BTF") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) [ sashal: Adapted btf_type_is_char_ptr/array hunks to the older code, which passes a &tid argument to btf_type_skip_modifiers() instead of NULL. ] Signed-off-by: Sasha Levin --- kernel/trace/trace_probe.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 4265518ce967c..1a0e03dc59c07 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -325,6 +325,9 @@ static bool btf_type_is_char_ptr(struct btf *btf, const struct btf_type *type) u32 intdata; s32 tid; + if (BTF_INFO_KIND(type->info) != BTF_KIND_PTR) + return false; + real_type = btf_type_skip_modifiers(btf, type->type, &tid); if (!real_type) return false; @@ -350,6 +353,11 @@ static bool btf_type_is_char_array(struct btf *btf, const struct btf_type *type) array = (const struct btf_array *)(type + 1); real_type = btf_type_skip_modifiers(btf, array->type, &tid); + if (!real_type) + return false; + + if (BTF_INFO_KIND(real_type->info) != BTF_KIND_INT) + return false; intdata = btf_type_int(real_type); return !(BTF_INT_ENCODING(intdata) & BTF_INT_SIGNED) -- 2.53.0