Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6894485rwn; Tue, 13 Sep 2022 10:26:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR56UijPkO91KagqBYVcBxfay9DM+5PFB01yWI392BzS1gsrS6ESM73ZR8hT4RD0DuVpO8dr X-Received: by 2002:a17:907:2d8a:b0:730:6880:c396 with SMTP id gt10-20020a1709072d8a00b007306880c396mr22224019ejc.192.1663089968479; Tue, 13 Sep 2022 10:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663089968; cv=none; d=google.com; s=arc-20160816; b=uNIUIhj7uWZpHEktdbrjDaK6f8J8gCiCMI0hAvtsh8akq63WSO5tFxkh5GBq0IUATD O2JT7k0XnJyi+HlV5ryciQI1nAAuu7gM5+KiBXjY0dq8irbS5ix/e8HQHgBTYV6BwBs1 dpdC9HhvOcHXA0wVCEsy+cimDOBjXG5HYRaf3psIPXYZ/HRCBRkVzUHw1adFL34Rr5td JZLq13l0HRQqDw6gkRl8UvBUL5z8v+N5G766REqpvI7kcWd5m69fiqg34ExXjzTB9eBy K4Ue49575XkvobRfX2/TQN+O/dV6jh5NNiHauyoMSwRo81XYpF+MaiOiRkoXhYwsT2tQ ua7g== 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=KPBME2vjHaJU1xPsU5etg8Va15pdHRQ37VrA9drEuGU=; b=HZo1n0tAfGSGDn3uJ3VVHQSRnPhm9yB7lJHFKvOsruZ3rmM1IqbDOTRVvYQLdoQxwr 8+VvzQ8tFRIN8j6E5CIA1pNAEBQiOKDZfjmI9ESrAQL/Mjr/7WOvI1kvcCIPM8v+mpbh TVitaQrSFZiYuh04qY8l0IRh/o8YJ4afejQ5nohILB6AjuDGlEVixAl7qb7i+JySF/C6 LyJQxEMpdbjlTpX+z2eslvizvxPI8oemhQlhEgm5pEt1uIvHQsr6YFePeheV7EDVOtpN CoRIXEhIyKBN2lKom+2jbnmmFD35g2sdg/f/lNVvQE9v8UaNoS9RvdOyMyL7Z0XyYh1f U9wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YjjIa1nX; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a170906974300b0073d15dfd9b7si11431807ejy.472.2022.09.13.10.25.41; Tue, 13 Sep 2022 10:26:08 -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=@linuxfoundation.org header.s=korg header.b=YjjIa1nX; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232670AbiIMRPp (ORCPT + 99 others); Tue, 13 Sep 2022 13:15:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232641AbiIMROx (ORCPT ); Tue, 13 Sep 2022 13:14:53 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EC5A1AD8E; Tue, 13 Sep 2022 09:03:24 -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 sin.source.kernel.org (Postfix) with ESMTPS id 5E829CE1281; Tue, 13 Sep 2022 14:17:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F8E7C43470; Tue, 13 Sep 2022 14:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078658; bh=VQo1ymelByDOIabi+qMStXzslI1hWPh7/22KgE1kAnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YjjIa1nXKMsQPiuz88CfdUFwVTG/fL4o5xFqtXJTuDhsrB1ihFz5qEjVfqs9h76A+ cFDFJ0DNhebVssirj0FVY0jv+PCsXBnm5d7SOaVLQD5rzRY43YZr4ZuJn+lKLdmQ5p 6m9rsu0JXLM5QlXvTXMy4248UhZCOExrW1ZLZvz0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Masami Hiramatsu (Google)" , "Steven Rostedt (Google)" Subject: [PATCH 5.15 032/121] tracing: Fix to check event_mutex is held while accessing trigger list Date: Tue, 13 Sep 2022 16:03:43 +0200 Message-Id: <20220913140358.731269290@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@linuxfoundation.org> User-Agent: quilt/0.67 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) commit cecf8e128ec69149fe53c9a7bafa505a4bee25d9 upstream. 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(). Link: https://lkml.kernel.org/r/166226474977.223837.1992182913048377113.stgit@devnote2 Cc: stable@vger.kernel.org Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events") Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_trigger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -128,7 +128,8 @@ static bool check_user_trigger(struct tr { 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;