From nobody Sun Feb 8 06:56:17 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 48877254AF5; Fri, 2 May 2025 13:16:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746191769; cv=none; b=oHF0cgFLNJ1Epr8Fwdgau72SuwcX8Lgk8onjLR0AhWSFsX6A4cD0mbt1c6hMw7EbzZ8z4Yg5YRa8/JUcogJonYiyF02dtph2hwTiudOB33WeJk+4drpzrMjJkDOp7OWdRykAzx4oY1fmlIZhiIuc+rvkO0MSX8tR7cmCHvrlTis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746191769; c=relaxed/simple; bh=6v+xVhxOY0UkacAOKqSthuE1TtEV5XtaFiVQyBzCxUs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZkjJ480pdfjZWiJ3yodXQmhF1rABvOD4Ak41hTTkrO5DTFuDGxpjARu+LiLvNGHRCOsoRhV6SiJZ8mqW7iKI/8qVq4Mt4mxgWIMhW4E97Wpp22umSOgSU/OM+0o2gDAh1yXIo7bFZfIV9hQXM+V+zNbmyUodom23TWhGPmzGsnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jFfYsuZR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jFfYsuZR" Received: by smtp.kernel.org (Postfix) with ESMTPS id C959CC4CEEE; Fri, 2 May 2025 13:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746191768; bh=6v+xVhxOY0UkacAOKqSthuE1TtEV5XtaFiVQyBzCxUs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jFfYsuZRzaZl/t3B4KZhhIjCc0eeYNeaOhn3DHLSEeE5yqvSgOXr+wOzM2qnYq0X6 YEdtkKwd+0GXo9QpVCWQoXSi3Y/ITqheBdDVm5S89DFr7KeWH0ONiYRdyjKwZ5g/uq Nz2aQVI7ucWZbsVGthyqDqmyyyRxik2/XOHqoglNAXnJYasxeNL/oR9NtVYGpgyWfV VMw7vnH9TpYAyH0lhFa16wPl4VzDkrLre2LjXKDV6RfVYo8+fwvssBdXdEYXabwOn+ PzODZ4IJd2/s8RdBU3K+s0OQv/QotrfLvAuYHXbFJ2BuqbnqDi5Gfzw680Lo0y0Ye7 cBDaHYiLbd4QA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBB1AC3ABAD; Fri, 2 May 2025 13:16:08 +0000 (UTC) From: Paul Cacheux via B4 Relay Date: Fri, 02 May 2025 15:15:52 +0200 Subject: [PATCH v2 1/2] tracing: add missing trace_probe_log_clear for eprobes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250502-fix-trace-probe-log-race-v2-1-511ecc1521ec@gmail.com> References: <20250502-fix-trace-probe-log-race-v2-0-511ecc1521ec@gmail.com> In-Reply-To: <20250502-fix-trace-probe-log-race-v2-0-511ecc1521ec@gmail.com> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Namhyung Kim Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Paul Cacheux X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1746191767; l=788; i=paulcacheux@gmail.com; s=20250422; h=from:subject:message-id; bh=Nem7XKEmMcHI5glWY7jEUqZtjAQzjhIH+nS5TNvLewM=; b=KYKG2TOWU5FBONQSxiwPiN1wLq7a9XhDN50L9Kbh9e7FpkO6aMz3g23Ztn47NNi6e7iybcHGw 7Hp1gCDmBfCDcnoXyC04q2UmUHOAg1G6R6PbulVP2t8ZQYh/FD0XP/4 X-Developer-Key: i=paulcacheux@gmail.com; a=ed25519; pk=8UguSecyECHKHp0YLS7hTEDob0ctFMr3ygBTeAmrFHs= X-Endpoint-Received: by B4 Relay for paulcacheux@gmail.com/20250422 with auth_id=386 X-Original-From: Paul Cacheux Reply-To: paulcacheux@gmail.com From: Paul Cacheux Make sure trace_probe_log_clear is called in the tracing eprobe code path, matching the trace_probe_log_init call. Signed-off-by: Paul Cacheux --- kernel/trace/trace_eprobe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c index c08355c3ef32b4124ac944d7e3a03efb66492269..916555f0de811f03feed9d923c6= 3078b0e4c993b 100644 --- a/kernel/trace/trace_eprobe.c +++ b/kernel/trace/trace_eprobe.c @@ -969,10 +969,13 @@ static int __trace_eprobe_create(int argc, const char= *argv[]) goto error; } } + trace_probe_log_clear(); return ret; + parse_error: ret =3D -EINVAL; error: + trace_probe_log_clear(); trace_event_probe_cleanup(ep); return ret; } --=20 2.49.0 From nobody Sun Feb 8 06:56:17 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4891D254AF6; Fri, 2 May 2025 13:16:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746191769; cv=none; b=JYR2UugXTAqUtsMPOsoM6uujPqshoycnH+lWEX5gnc9wLNALYHxTANcxiLpMbgJ/vEIHNtXe/NBo3IXm52HjQcYwJEFfENgfus2fbpntEJk7flrBwfYgKJmjgfR6+TgwEE133tJ2VeDmbyHCKbrUlQ+SKTqtq2W0Qk5Sb5TIUmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746191769; c=relaxed/simple; bh=TNGKJsHFD9W/hweRfsyrGNZ62fbkiaEiQ9aAoscBr08=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b8oDh74LFFeeGa6RXO7UW6ZS6/BaqsTdw6ZHXdZ9gTVJ9dRltZNqInXbmu/nRX2+9SFZ79baxCTX1/hbaNJ8iMHyx/b/d35hGGpl7Kya5Sgs5y55fuIcxyiKFF9Vq5Qz/PcV93U8lq6g6/E9VPyWQerpIzPRxuQBwqSz+vjUu5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JUb1uSA4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JUb1uSA4" Received: by smtp.kernel.org (Postfix) with ESMTPS id D2021C4CEEB; Fri, 2 May 2025 13:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746191768; bh=TNGKJsHFD9W/hweRfsyrGNZ62fbkiaEiQ9aAoscBr08=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=JUb1uSA4Xftxk0q+8kdYpdMf/nINyybwvVRTvy8qexEEgDRpTi1S3Gw2tgLhzQbeL GztTkyacQn7AdQHYfSjMr2GKqWv3IO7N+mT+kE3RLfmbnM9tjv0BnuZEbKrPveugy5 kVdpnOhYN+ExEOwdrM1cYbelTmBguSzkijEEwNvEdxXdfu+vHuDtoRLMXF/GNdKnme 7v4W3KuLbmGx1Knz1HFE7pfdKx4J7aNjCfHBmg9JPVh5K6CoPWtIZ2GKtsboLrhA6t CuJpJoayuAbqT5ryB3tTASG+UZB5UP3cs8bJPFv6l6C9NyYEMcPzSPlnS+r9M6u5TN ut8Ez0zE0YIzg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C621BC3ABAA; Fri, 2 May 2025 13:16:08 +0000 (UTC) From: Paul Cacheux via B4 Relay Date: Fri, 02 May 2025 15:15:53 +0200 Subject: [PATCH v2 2/2] tracing: protect trace_probe_log with mutex Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250502-fix-trace-probe-log-race-v2-2-511ecc1521ec@gmail.com> References: <20250502-fix-trace-probe-log-race-v2-0-511ecc1521ec@gmail.com> In-Reply-To: <20250502-fix-trace-probe-log-race-v2-0-511ecc1521ec@gmail.com> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Namhyung Kim Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Paul Cacheux X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1746191767; l=1822; i=paulcacheux@gmail.com; s=20250422; h=from:subject:message-id; bh=JoafqU4uAGl3ydwos4FNrWPAGaAC2MqNPKDgQHWMZCs=; b=KcHSfL163DKlJ1NliuUUMQWzwqr+MsVP+H2ve6fE7oWXWJIIhlwtWCk5QHPT/9rTaAJKOXtz9 bdzZoYkn6hnDJpyf2/hgWq0lNlOdrSgxB9BIXHG4TaBqtYSIu27wspw X-Developer-Key: i=paulcacheux@gmail.com; a=ed25519; pk=8UguSecyECHKHp0YLS7hTEDob0ctFMr3ygBTeAmrFHs= X-Endpoint-Received: by B4 Relay for paulcacheux@gmail.com/20250422 with auth_id=386 X-Original-From: Paul Cacheux Reply-To: paulcacheux@gmail.com From: Paul Cacheux The shared trace_probe_log variable can be accessed and modified by multiple processes using tracefs at the same time, this new mutex will guarantee it's always in a coherent state. There is no guarantee that multiple errors happening at the same time will each have the correct error message, but at least this won't crash. Fixes: ab105a4fb894 ("tracing: Use tracing error_log with probe events") Signed-off-by: Paul Cacheux --- kernel/trace/trace_probe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 2eeecb6c95eea55502b83af6775b7b6f0cc5ab94..14a7a0b59cd20a8bc43e3e7c653= e986081f924c8 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -154,9 +154,11 @@ static const struct fetch_type *find_fetch_type(const = char *type, unsigned long } =20 static struct trace_probe_log trace_probe_log; +static DEFINE_MUTEX(trace_probe_log_lock); =20 void trace_probe_log_init(const char *subsystem, int argc, const char **ar= gv) { + guard(mutex)(&trace_probe_log_lock); trace_probe_log.subsystem =3D subsystem; trace_probe_log.argc =3D argc; trace_probe_log.argv =3D argv; @@ -165,11 +167,13 @@ void trace_probe_log_init(const char *subsystem, int = argc, const char **argv) =20 void trace_probe_log_clear(void) { + guard(mutex)(&trace_probe_log_lock); memset(&trace_probe_log, 0, sizeof(trace_probe_log)); } =20 void trace_probe_log_set_index(int index) { + guard(mutex)(&trace_probe_log_lock); trace_probe_log.index =3D index; } =20 @@ -178,6 +182,8 @@ void __trace_probe_log_err(int offset, int err_type) char *command, *p; int i, len =3D 0, pos =3D 0; =20 + guard(mutex)(&trace_probe_log_lock); + if (!trace_probe_log.argv) return; =20 --=20 2.49.0