Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp76712pxv; Wed, 21 Jul 2021 16:12:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZsxTjNmXYn7ySzCs6HIyj3/aDW5kIF0s2Svx8DBLbtRKAWcfdbffHOfK0B/cIPQ8WXCvQ X-Received: by 2002:a05:6e02:78c:: with SMTP id q12mr26831981ils.243.1626909128943; Wed, 21 Jul 2021 16:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626909128; cv=none; d=google.com; s=arc-20160816; b=yhOJV7LuPhO1Yy7vQsOS0T2bQD56qKpDw4qDm2HYCBXRmVDSVAkwqgkIPlzMl6ka30 1ThSSpMqIdiWaU80/XNf1m7Od3LtMCMHDKJH+Neu3kWUTSfMFgkiGPEVWyVAT53aQBDt D1uzIKNps/2MnlzoGBm+TXVqHbzeo3XTcnx7KZnrDSyM5JPQOqAIo6/yq9xKt9/Ci4BL JtezlwfLcVtGUC9h3u+ih8qmLfi1tXY5/tQRAT+dImbD4woksoZT0hAtVoccIdTJ6ZCD 5nCno87XWUiHBNXd17PSqAJ77w5IkEBc7tiQO4ZMllijsGksYKUYFMeg/cC4Tzv54+ZE Czvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:subject:cc:to:from:date; bh=NrIOxgfRbYjn4g+PGK0WmZKcAGGXs1UYd4F6V1Xm+cI=; b=1CrLqfl2/QRtvSXXM2YUCf3aCKzawPvEBxze9mqoHmGymlSEUKK8wJvzk5D8TakoHJ NfCqOxTbw0INKmXqNVWeg5BtMvMTRCak2KYhmM5dzvsOnKtSHzFgmIVZ28lWgmrzXj+h q2vzz64vKn8n8l5MsrMbUPEylpYHM+W2XV5xMr8rFFf6AaGjxjn6CLnKA34wLreRkpe0 G9IgWUykQhiIo/4u5J1GqHmjPlXA8A5trIifE5i+tGlIIpZHCn2oYdcEmQd5ZBfLB42u InZW4qXO6lPuabwnQO+GCcKTxOLHFC2Ic79+SJxyb2ySUCgXi17g7O0lQ2jwfi1yguNb 6FIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q23si14594634jav.118.2021.07.21.16.11.57; Wed, 21 Jul 2021 16:12:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230422AbhGUW3k (ORCPT + 99 others); Wed, 21 Jul 2021 18:29:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:51330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbhGUW3j (ORCPT ); Wed, 21 Jul 2021 18:29:39 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 098E8610F7; Wed, 21 Jul 2021 23:10:14 +0000 (UTC) Date: Wed, 21 Jul 2021 19:10:08 -0400 From: Steven Rostedt To: LKML Cc: Tom Zanussi , Masami Hiramatsu , Namhyung Kim , Ingo Molnar , Andrew Morton Subject: [PATCH] tracing: Synthetic event field_pos is an index not a boolean Message-ID: <20210721191008.638bce34@oasis.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Steven Rostedt (VMware)" Performing the following: ># echo 'wakeup_lat s32 pid; u64 delta; char wake_comm[]' > synthetic_events ># echo 'hist:keys=pid:__arg__1=common_timestamp.usecs' > events/sched/sched_waking/trigger ># echo 'hist:keys=next_pid:pid=next_pid,delta=common_timestamp.usecs-$__arg__1:onmatch(sched.sched_waking).trace(wakeup_lat,$pid,$delta,prev_comm)'\ > events/sched/sched_switch/trigger ># echo 1 > events/synthetic/enable Crashed the kernel: BUG: kernel NULL pointer dereference, address: 000000000000001b #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP CPU: 7 PID: 0 Comm: swapper/7 Not tainted 5.13.0-rc5-test+ #104 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016 RIP: 0010:strlen+0x0/0x20 Code: f6 82 80 2b 0b bc 20 74 11 0f b6 50 01 48 83 c0 01 f6 82 80 2b 0b bc 20 75 ef c3 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 <80> 3f 00 74 10 48 89 f8 48 83 c0 01 80 38 9 f8 c3 31 RSP: 0018:ffffaa75000d79d0 EFLAGS: 00010046 RAX: 0000000000000002 RBX: ffff9cdb55575270 RCX: 0000000000000000 RDX: ffff9cdb58c7a320 RSI: ffffaa75000d7b40 RDI: 000000000000001b RBP: ffffaa75000d7b40 R08: ffff9cdb40a4f010 R09: ffffaa75000d7ab8 R10: ffff9cdb4398c700 R11: 0000000000000008 R12: ffff9cdb58c7a320 R13: ffff9cdb55575270 R14: ffff9cdb58c7a000 R15: 0000000000000018 FS: 0000000000000000(0000) GS:ffff9cdb5aa00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000000001b CR3: 00000000c0612006 CR4: 00000000001706e0 Call Trace: trace_event_raw_event_synth+0x90/0x1d0 action_trace+0x5b/0x70 event_hist_trigger+0x4bd/0x4e0 ? cpumask_next_and+0x20/0x30 ? update_sd_lb_stats.constprop.0+0xf6/0x840 ? __lock_acquire.constprop.0+0x125/0x550 ? find_held_lock+0x32/0x90 ? sched_clock_cpu+0xe/0xd0 ? lock_release+0x155/0x440 ? update_load_avg+0x8c/0x6f0 ? enqueue_entity+0x18a/0x920 ? __rb_reserve_next+0xe5/0x460 ? ring_buffer_lock_reserve+0x12a/0x3f0 event_triggers_call+0x52/0xe0 trace_event_buffer_commit+0x1ae/0x240 trace_event_raw_event_sched_switch+0x114/0x170 __traceiter_sched_switch+0x39/0x50 __schedule+0x431/0xb00 schedule_idle+0x28/0x40 do_idle+0x198/0x2e0 cpu_startup_entry+0x19/0x20 secondary_startup_64_no_verify+0xc2/0xcb The reason is that the dynamic events array keeps track of the field position of the fields array, via the field_pos variable in the synth_field structure. Unfortunately, that field is a boolean for some reason, which means any field_pos greater than 1 will be a bug (in this case it was 2). Cc: stable@vger.kernel.org Fixes: bd82631d7ccdc ("tracing: Add support for dynamic strings to synthetic events") Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/trace_synth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_synth.h b/kernel/trace/trace_synth.h index 6e146b959dcd..4007fe95cf42 100644 --- a/kernel/trace/trace_synth.h +++ b/kernel/trace/trace_synth.h @@ -14,10 +14,10 @@ struct synth_field { char *name; size_t size; unsigned int offset; + unsigned int field_pos; bool is_signed; bool is_string; bool is_dynamic; - bool field_pos; }; struct synth_event { -- 2.31.1