Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3729797ybv; Mon, 10 Feb 2020 05:26:59 -0800 (PST) X-Google-Smtp-Source: APXvYqw+fZbg5vkeVW/ywPqpWpdJ2yX/GuXU4lCy1QbpW/5Of4be8w02MsbvPtbUxPJXaMwMJ9WQ X-Received: by 2002:aca:c383:: with SMTP id t125mr759499oif.122.1581341219544; Mon, 10 Feb 2020 05:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581341219; cv=none; d=google.com; s=arc-20160816; b=LNiEH1oNaRApv+0koZTkt/KG6noL/UJyWzsGj3fVcenucTl0tjo4ZtCNkaFYJ0hy3L UsQTovkNQ3zNByogz5UY1/AzDWV9JDFGjTtQjBrTk6q+BYudp3Zsz9VqdKb6qQp3zNJ2 ed+sNB5BWxU+e8fpBSLPSgxmgVO4NOszUMvjP/p4ThUbHDv/yZzZyx5Xo0UFwfRiOWHX cZKOYlpG2veG+HU64OXP1tj6UJnMQx9NmCMl6MU3VqXHICAdRr3m8PEi5SbcyHBRz4M2 deN+BnUNzAlilYy87R3GZB3WG5HzgMvEX2wxftQfP/OswguvBIxt+VFgALRysleIKO9X uzUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SRAG49sOpIIq3P3EHgoopiDDQ3/ZMbcu9uaxw6AnApI=; b=iBJ9cBdEjTTNmrhHy+mLwn9U8tJLeUo75PzGABdccuNNq2x7YIdfv/wuQhJ48+IKnu pjOor+ovoDLgmp+tMVqdM4EY3mbLv1n7MQGbG74Shx+zz+3D5qxIGwwamvoM449UaG3F rmDeN7TUbczv6ZXFKdjD8iNfoO6blWomgMvLbTCRIfQOuUneKKV6sp8ORqHUpNptjYuO 9Br6YNnsQ/xJdjqZmVuEAHj92j6os2cZsyp8BGczVrYvbFXzIE3KQvesgYrrT2jVwsKw 5utUMzeSfl69N2WfcO3GBJUNcLjwzE5ePK/7E/xvLvXmTmBFhQJqc57Rkt1HVchkZxzd S0FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WVjiRPaU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l83si166470oih.58.2020.02.10.05.26.47; Mon, 10 Feb 2020 05:26:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WVjiRPaU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730346AbgBJN0X (ORCPT + 99 others); Mon, 10 Feb 2020 08:26:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:56722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727922AbgBJMgr (ORCPT ); Mon, 10 Feb 2020 07:36:47 -0500 Received: from localhost (unknown [209.37.97.194]) (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 A83D42173E; Mon, 10 Feb 2020 12:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338206; bh=V4Vj4iXVZCOwvr/0Kky48M0kWDdquu7/d64KrYgidMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WVjiRPaUM4KClPvJ5Manv0w0NbiwE4yuhsYUwXfSdInHiCi6ShzqAfh3/HB86GShR Hdsj7JwOk3oaXPz/s1Kat1ayxc3mISvH2eIxUm3fX48ReBpOgJK/1Pqc8xaUlZXpXc VjUBC8xO7IwMtHx+Nr4r2nNRys5NfeBPzr1xdLdI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" , "Joel Fernandes (Google)" , Peter Zijlstra , Thomas Gleixner , "Paul E. McKenney" , syzbot+774fddf07b7ab29a1e55@syzkaller.appspotmail.com, Mathieu Desnoyers Subject: [PATCH 5.4 027/309] tracing: Fix sched switch start/stop refcount racy updates Date: Mon, 10 Feb 2020 04:29:43 -0800 Message-Id: <20200210122408.603857143@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Desnoyers commit 64ae572bc7d0060429e40e1c8d803ce5eb31a0d6 upstream. Reading the sched_cmdline_ref and sched_tgid_ref initial state within tracing_start_sched_switch without holding the sched_register_mutex is racy against concurrent updates, which can lead to tracepoint probes being registered more than once (and thus trigger warnings within tracepoint.c). [ May be the fix for this bug ] Link: https://lore.kernel.org/r/000000000000ab6f84056c786b93@google.com Link: http://lkml.kernel.org/r/20190817141208.15226-1-mathieu.desnoyers@efficios.com Cc: stable@vger.kernel.org CC: Steven Rostedt (VMware) CC: Joel Fernandes (Google) CC: Peter Zijlstra CC: Thomas Gleixner CC: Paul E. McKenney Reported-by: syzbot+774fddf07b7ab29a1e55@syzkaller.appspotmail.com Fixes: d914ba37d7145 ("tracing: Add support for recording tgid of tasks") Signed-off-by: Mathieu Desnoyers Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_sched_switch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/kernel/trace/trace_sched_switch.c +++ b/kernel/trace/trace_sched_switch.c @@ -89,8 +89,10 @@ static void tracing_sched_unregister(voi static void tracing_start_sched_switch(int ops) { - bool sched_register = (!sched_cmdline_ref && !sched_tgid_ref); + bool sched_register; + mutex_lock(&sched_register_mutex); + sched_register = (!sched_cmdline_ref && !sched_tgid_ref); switch (ops) { case RECORD_CMDLINE: