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 A60AD39EF05; Mon, 17 Aug 2026 14:42:30 +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=1786977751; cv=none; b=ItH+9vIdgf1xt/FV3NpKZCykXkY0bobzvNZJ1I+52lSkdy7Ngdad+7Zyx9GL//EcVVe/ThJSxUdcDyKRQDEfr/7WoNCNE3dqlBYjclsEXIirJ6mM6hRt39mg4cMjo5ohs4dn2K/vPIFrGnJYU7lTFNjo6O3Fk1MH1VoxR34z+tI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786977751; c=relaxed/simple; bh=+CBaL/FBCRZP8LF0KZyIRgtSU/BZhFaxTRkM+4ktwuw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gU4MbWOgJvQBmov0yVRMGbiwL/waKZbV+gPViY5CgedEvomc9WEBaFIV/o3wjWoXgGBUmQC643ZhDhJxD3lv9BCmWGVuQmVPxxV0Dc8iPZ4hdV13n/np+l8fkOJHtq8g/FiVqf7fgsayaHiVBWw8BuXWYoNOdtiNP7T42OycgEo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HjU6ZPd3; 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="HjU6ZPd3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 052D51F000E9; Mon, 17 Aug 2026 14:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786977750; bh=GRmela56hTt+0pyU5TzmTyAhaCKirbCXqEO4KdHvY0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HjU6ZPd3hOUaw65i67/PVDHgXCCH1M9XT8bDt84EMrpaQcmIi0AZF0X99+eFkcCsD sHlvwOmjNkm0wT4j+KPCeEMDT7o7mwOaKBxNIwyaWHBkjjvYLLxlwM1e5EjxVP20B3 lOQricTwOUrVx/xTYx2uvvj7+ddsR2WaWXKMAnHE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Wu , Steven Rostedt Subject: [PATCH 5.15 435/456] tracing: Fix race between update_event_fields and, event_define_fields Date: Mon, 17 Aug 2026 15:33:45 +0200 Message-ID: <20260817132556.134881167@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132539.792407575@linuxfoundation.org> References: <20260817132539.792407575@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Wu commit c3730b8373bb5059d735509b9e6a00d7eb337d7c upstream. The following sequence may leads race between event_define_fields() and update_event_fields(): CPU0 (loads module A) CPU1 (loads module B) =============================== =============================== load_module(A) load_module(B) notifier_call_chain notifier_call_chain trace_module_notify trace_module_notify mutex_lock(&event_mutex) trace_event_update_all() trace_module_add_events(A) down_write(&trace_event_sem) __register_event(call_A) __add_event_to_tracers(call_A) event_define_fields(call_A) for each f: list_for_each_entry(field, list_add(&f->link, &class->fields, link) &class->fields) field = class->fields->next; Where access to the class->fields is not protected by the event_mutex in trace_event_update_all(). This produces the following panic: Unable to handle kernel access ... at virtual address 0000000000000018 pc : update_event_fields+0xf8/0x368 Call trace: update_event_fields+0xf8/0x368 trace_event_update_all+0x7c/0x2b4 trace_module_notify+0x4c/0x1dc notifier_call_chain+0x84/0x168 blocking_notifier_call_chain_robust+0x64/0xd4 load_module+0x10c8/0x123c __arm64_sys_finit_module+0x230/0x31c Fix by taking event_mutex in trace_event_update_all() before trace_event_sem. Cc: stable@vger.kernel.org Fixes: b3bc8547d3be ("tracing: Have TRACE_DEFINE_ENUM affect trace event types as well") Link: https://patch.msgid.link/2e5730d2-c631-da41-3a3a-ae35bb4895f3@allwinnertech.com Signed-off-by: Michael Wu Signed-off-by: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2875,6 +2875,7 @@ void trace_event_eval_update(struct trac int last_i; int i; + mutex_lock(&event_mutex); down_write(&trace_event_sem); list_for_each_entry_safe(call, p, &ftrace_events, list) { /* events are usually grouped together with systems */ @@ -2908,6 +2909,7 @@ void trace_event_eval_update(struct trac cond_resched(); } up_write(&trace_event_sem); + mutex_unlock(&event_mutex); } static struct trace_event_file *