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 CADAF3BB67F; Sat, 17 Oct 2026 16:52:27 +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=1792255948; cv=none; b=X52aeCcE01lKAyps1ircszvj1cjPwjPnX1g8SD4DibnL9cov9qYU+RyGhWsuQLg0gz21PtxE53bEY4bKt5HRTrTqcjJvnKECDHNOslFvdHe2FPHTSkbZcctlu8wFVLBsfjTV4hT7mWLusrh5ntbKWdLGAFs+fIeZnrLvJJ5v0CI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792255948; c=relaxed/simple; bh=JUVoJvog7LubAb78x9m/ElxcIQQD3t7Zz5m+dyzH1MQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fjmy4YdcUIFV27OVrei2DwSEHItsAhoVLGOG1LqslxILquLpcHtjDpPFZd0eE0oXhNJWj/+lo/OBxDE/aW4l3L1Kd6QO3WLHTWC4Eo14N2oXhGI2Hpuwz3+dU7CycI6esg2WZX4t2217B4uiESPZlEQ7bOiA5VMd0kRO+1fM4sI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WXEPjwo9; 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="WXEPjwo9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23D2C1F000C4; Sat, 17 Oct 2026 16:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792255947; bh=kEyoaEhVJJjg5NjTdg3gOkY/WLO7EQuArR//jDy7p20=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WXEPjwo9Pf0vOGQ3ICGRjC/K922GOE/ttqKj9K0XkIhpvJD5CKQvKibUf9L8Zcauy t3GuPAzghXsr1XEKNQ4VsYHHHlQIoluImov0+vS0M8mbzw0I0XRm9O8cWqSsCSiUxx DIcAXhSzDY5TEdxxatehwg49UWqtiuGLLROCysZ8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Donggeun Yoo , Steven Rostedt , Sasha Levin Subject: [PATCH 6.6 0032/1674] tracing: Fix memory corruption from a "STACKTRACE" histogram key Date: Sat, 17 Oct 2026 17:38:24 +0200 Message-ID: <20261017160431.965632297@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@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: Donggeun Yoo [ Upstream commit 7f711e62355bb3123a2ca2f97a2facbfebc678c6 ] "cpu", "CPU", "stacktrace" and "STACKTRACE" are generic fields, defined with an offset and a size of zero so that the filter code can match them by name. parse_field() maps them onto their common_* equivalents for backward compatibility, but unlike the common_* names it hands the placeholder back to the caller instead of NULL. create_hist_field() takes a non-NULL field as a promise that the record carries a stacktrace and picks HIST_FIELD_FN_STACK, so the __data_loc word is read from offset 0, that is from common_type, and its low 16 bits are followed as an offset into the record. What is found there becomes the length of an unbounded memcpy. Pick an event whose id is small enough that the offset stays inside its own record and the length is a kernel text address: # cd /sys/kernel/tracing # echo 'hist:keys=STACKTRACE' > events/ftrace/print/trigger # echo hello > trace_marker Oops: general protection fault, probably for non-canonical address RIP: 0010:rb_next+0x23/0x60 RIP: 0010:memcpy+0xc/0x30 event_hist_trigger+0x2e7/0x12c0 Kernel panic - not syncing: Fatal exception in interrupt Leave the field NULL, which is what the comment above the branch says the code does and what common_stacktrace already does. FILTER_CPU and FILTER_COMM are left alone, their create_hist_field() branches never look at the field. Cc: stable@vger.kernel.org Fixes: 4b512860bdbd ("tracing: Rename stacktrace field to common_stacktrace") Link: https://patch.msgid.link/20260907155045.692664-3-donggeunyoo.kernel@gmail.com Signed-off-by: Donggeun Yoo Signed-off-by: Steven Rostedt [ Adjusted context for the missing FILTER_COMM branch in parse_field(). ] Signed-off-by: Sasha Levin --- kernel/trace/trace_events_hist.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 3ea423c62448a..d96faf3436a05 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -2379,6 +2379,7 @@ parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file, *flags |= HIST_FIELD_FL_CPU; } else if (field && field->filter_type == FILTER_STACKTRACE) { *flags |= HIST_FIELD_FL_STACKTRACE; + field = NULL; } else { hist_err(tr, HIST_ERR_FIELD_NOT_FOUND, errpos(field_name)); -- 2.53.0