Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp1615201rwb; Sat, 3 Sep 2022 21:22:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR6N6VoKFUiiGvS323dQAHGxwtkO6JumogCuZ6WP5W8UWJtbt3vwkHsUvtIgnviJx+8aEuML X-Received: by 2002:a17:907:868f:b0:730:bc1f:a8d8 with SMTP id qa15-20020a170907868f00b00730bc1fa8d8mr33558383ejc.106.1662265359268; Sat, 03 Sep 2022 21:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662265359; cv=none; d=google.com; s=arc-20160816; b=u49czUALuHBleOcq7pekKivXuR88p5GcfOyq6sdKuu1evABKkJIoabssVUhApYvFEd RJoMUKK9IBTedeWUimdcR/0yXjpYa3471OMfFX+xQ9fNVxODax1I7qisgr+1TTZtHr10 focj5Q9XyWlWEv5o6d4pOEeG///7n54buKa43yReL2UvU36l+A9FdMXXYotXZnKRjB0J HF9uiV7NenpaT6O6XMMjCLV5hxv7RnyZnXC9z8QCXOS/TDRG4UZXxcEzbs7i/0gcblAb 5nQYt0+W+6WAebOT8wEmCRmx1K5ufF4RkO3A6irHmizUDy5XWDzYzJ/VSrz3PJ3lnM/n RVnQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3IR4wPrhxID8JlkAua1r0ncgdieG6qUSX4ys62lxJ3A=; b=hzT6t+IG+KHTM3MYAvhvwIXEeMiZa1IPLbkKsGLh+kpd855NWDmNDxoIBX4pqpWTw1 urg6ZxJWI4DIg0EptF/SLJlLQrENm/Vrcu/v04eHXPP2+I7PpjdkQaGyZPPlrXQA3eCi 13I8Vx8TRX2F2cMkiGMGTHB7baMlAHh0971Y9UctBIi7FcWGJEZ+3bl0N/TRlWXZXKlm xXN5cyoH6+1K++5AFKpR4vMfE2dczdB6UBS8ii3L3++/Z5UvhQiKDeFEmXDXfXAEKYaX HgczodVVn8FmPhu7Ewzem6SiPFvEFPrLo7BfWn+4upt8QgYp+2taPhrO6lVRZTROrqR4 jTYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h3krUUwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ka17-20020a170907991100b0073c12a7e89esi4748229ejc.940.2022.09.03.21.22.13; Sat, 03 Sep 2022 21:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h3krUUwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232054AbiIDEMp (ORCPT + 99 others); Sun, 4 Sep 2022 00:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230320AbiIDEMh (ORCPT ); Sun, 4 Sep 2022 00:12:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8846A4AD5C for ; Sat, 3 Sep 2022 21:12:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 148FFB80C9E for ; Sun, 4 Sep 2022 04:12:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 889B9C433D6; Sun, 4 Sep 2022 04:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662264753; bh=tu/uBFTcTkD8ciezaLIOud2OqZdulEjwj2vtD/px5uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h3krUUwZyDHVYmtOAfdpwCbD3cNTV7riPHLvp+r5I/xkefZHN5pr/kebn6G7QHhCV xgvlp7TTcQ8G+wAk48cFInW/bzYJNPFjZi7ksEr+afZQIzLmsSRjnHhpsQOrjQ27PS SbotkMUUImvErJmgpf0ogxvq7BMk7TErbkA9sbM1vFTXTjolIkXHuiCpf4MJ+etlfG HbiqICGUfaciYjo+8+RFL5nzEEU8Gp2tRTeSCqTmgXU//EnFVAXJ6EkbelyzE0Vp5J H2TNwpbU+EBE+AQODjpb3YGU+J/AIG8FwUDpfB92rUHq0Z5biN0CBDySQa5qIGXYzJ lhYTGOyYqTArQ== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Tom Zanussi , Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH v5 2/6] tracing: Fix to check event_mutex is held while accessing trigger list Date: Sun, 4 Sep 2022 13:12:29 +0900 Message-Id: <166226474977.223837.1992182913048377113.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <166226473132.223837.9011128463174539022.stgit@devnote2> References: <166226473132.223837.9011128463174539022.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu (Google) Since the check_user_trigger() is called outside of RCU read lock, this list_for_each_entry_rcu() caused a suspicious RCU usage warning. # echo hist:keys=pid > events/sched/sched_stat_runtime/trigger # cat events/sched/sched_stat_runtime/trigger [ 43.167032] [ 43.167418] ============================= [ 43.167992] WARNING: suspicious RCU usage [ 43.168567] 5.19.0-rc5-00029-g19ebe4651abf #59 Not tainted [ 43.169283] ----------------------------- [ 43.169863] kernel/trace/trace_events_trigger.c:145 RCU-list traversed in non-reader section!! ... However, this file->triggers list is safe when it is accessed under event_mutex is held. To fix this warning, adds a lockdep_is_held check to the list_for_each_entry_rcu(). Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events") Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/trace_events_trigger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index cb866c3141af..918730d74932 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -142,7 +142,8 @@ static bool check_user_trigger(struct trace_event_file *file) { struct event_trigger_data *data; - list_for_each_entry_rcu(data, &file->triggers, list) { + list_for_each_entry_rcu(data, &file->triggers, list, + lockdep_is_held(&event_mutex)) { if (data->flags & EVENT_TRIGGER_FL_PROBE) continue; return true;