From patchwork Thu Nov 24 14:47:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 25589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3440846wrr; Thu, 24 Nov 2022 06:50:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Uy0NjCBqPPiV+7XHVUaJgVt/REEJX+sZRtN0e9RlinGmUa2FvixjuxvfsW95AhQawBhC0 X-Received: by 2002:a17:903:2311:b0:174:4ab2:6457 with SMTP id d17-20020a170903231100b001744ab26457mr26972220plh.118.1669301446588; Thu, 24 Nov 2022 06:50:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669301446; cv=none; d=google.com; s=arc-20160816; b=MZitgg07NeAri9HqoDGYjZus3inokFXOz2AmKfv13hzqwOkg89rcTptA9mo5GIN4OH 6THjAC6SFARVkfrRnKTwowTYMheMzh93Ldy2B/BwO13aBFLhzC14XIGs/53I8SQzjvHo IuFZ/Ns+5pSga0IvGwbFeogVj+iXijboxXfotIozVmNtjn1scSzjbMG5/PR5Hvj/7H8o iztLKNGoepj/S2k8qhd6LdsUIcXFilfyjoZ9mnai2+oXNdoFODUZuIFLrm1YJIr9yd0K vwyBoD1CvbYHIo0xVN0/VZKRU6GbC/aMq9VD2pAXxZaI1dzUKelMBTFmuWfQGJqOl1c2 vkmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=gjdqoK5M3rdP8LIzz562ZDEdFcO87Y1RWoUASFYLcLg=; b=HXbFZBg9jzyEV3FvO1NICPg7++6/Cv6yu1iDgKLSY95kWml26RK5ez3pwEYH61Gsl2 iwgO6McjtT3U5gDjZe7tiG5cPRLI1uR55YFiCaMZD31xFFYs/nppiRiYFKOVn/ypX0tt qDfCne+gIB8CiXvf+C2fIo92YrSv5P/OETxBEdUDlez4E2RxgxxAxdjt8zaRXpiqGk/9 bDenysvguypzwv7LBKUSXSOJbQ+ujZrjM2F3xSkvCg3/zDxFIdp/t0R6hJFwhm6jbUNA vMQa2hqONi0X9Z0BQ/dAlIFIO3VgNEPmaEDQJ8gnupxm4HJrrIyf6z9AfDlg5K/V7U3l h2tQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a63dd14000000b0047466dc1defsi1590323pgg.293.2022.11.24.06.50.33; Thu, 24 Nov 2022 06:50:46 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbiKXOsa (ORCPT + 99 others); Thu, 24 Nov 2022 09:48:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbiKXOs1 (ORCPT ); Thu, 24 Nov 2022 09:48:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F64EE0740; Thu, 24 Nov 2022 06:48:26 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id AE02062184; Thu, 24 Nov 2022 14:48:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BD6EC43146; Thu, 24 Nov 2022 14:48:25 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1oyDWa-001WsR-0V; Thu, 24 Nov 2022 09:48:24 -0500 Message-ID: <20221124144824.035022085@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 24 Nov 2022 09:47:56 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , Tom Zanussi , stable@vger.kernel.org Subject: [for-linus][PATCH 4/6] tracing: Fix race where histograms can be called before the event References: <20221124144752.427194398@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750389433631220316?= X-GMAIL-MSGID: =?utf-8?q?1750389433631220316?= From: "Steven Rostedt (Google)" commit 94eedf3dded5 ("tracing: Fix race where eprobes can be called before the event") fixed an issue where if an event is soft disabled, and the trigger is being added, there's a small window where the event sees that there's a trigger but does not see that it requires reading the event yet, and then calls the trigger with the record == NULL. This could be solved with adding memory barriers in the hot path, or to make sure that all the triggers requiring a record check for NULL. The latter was chosen. Commit 94eedf3dded5 set the eprobe trigger handle to check for NULL, but the same needs to be done with histograms. Link: https://lore.kernel.org/linux-trace-kernel/20221118211809.701d40c0f8a757b0df3c025a@kernel.org/ Link: https://lore.kernel.org/linux-trace-kernel/20221123164323.03450c3a@gandalf.local.home Cc: Tom Zanussi Cc: stable@vger.kernel.org Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events") Reported-by: Masami Hiramatsu (Google) Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_hist.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 087c19548049..1c82478e8dff 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -5143,6 +5143,9 @@ static void event_hist_trigger(struct event_trigger_data *data, void *key = NULL; unsigned int i; + if (unlikely(!rbe)) + return; + memset(compound_key, 0, hist_data->key_size); for_each_hist_key_field(i, hist_data) {