Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2203797imm; Thu, 27 Sep 2018 09:01:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV60Ph6ofKsM0Ka3fTjvIN2P5yrWPgmfIBfG1UlnW04BbbhxikG2LxKyoqjYN4Uxar3zAZrz9 X-Received: by 2002:a63:f15:: with SMTP id e21-v6mr10693251pgl.354.1538064068531; Thu, 27 Sep 2018 09:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538064068; cv=none; d=google.com; s=arc-20160816; b=JGbEi+77RSUzUF4NVD05B81plGx7fnlNIJtUVhk1HY3S3xfr7In9ZMTio3Fa9+t6Oh zx7hxqC3D62mY7uEbE1+eMin1nbkU0OWvMxst2hd7q8QEALXLkPYdf+hPdzA/a0UBJ6p b25fZIkX0dkLl17UcMWU318w2XU0de8kF7WGiS+DACpB1T06ZKmENV12hh9quB77eXmz tp3kji4vLr7U/yyUwk2idVG5lGhKOBb94qnHJuw4ErDwI7vYSxEmhU8wqqw6wzulFris AK0TsSI5TfMi+pP/ynqE3KClNI579yiqEE6WU3FCycCVtzPQ+LJJm8hX6cYfWpcFfBDL sdng== 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=O/JWxckLLzk5drBlkz83bv7lZNbBBqVv2wlJ1SEQjjM=; b=b/YJXRRpQLWqJVM0cMsP9fWukrx8LXirSVjuSNgcNR+SJrsIqMJLMp2FKeflqhJDxo 8dDI7KcT/YLlYkXCkc4fc9WLqQeB24ClYnYdmxNMg7ljmB8QQJmNUzZsNNXGSpKpW123 DHQZ/ch4stml9/fW4W43s8YYYiWfECXZZEdqNfmEAbkZeYhAiKYf8d8C+mjG/ipG8o/a dMJ+fVyuLnf9qvQt3bHp3n3w+ItK0HsxsJ46DXqh7xqxe+ERPoJZXe4g4uSsuLxqe2hI +DWyiexdMM5xdmagt5ksmyNfNYnyXxaB3mV6aREUKQbT37bmSO2ofccYZbIC+yRfNgMu LGpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kIksGwe2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z189-v6si2443141pfb.26.2018.09.27.09.00.52; Thu, 27 Sep 2018 09:01:08 -0700 (PDT) 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=kIksGwe2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727867AbeI0WSV (ORCPT + 99 others); Thu, 27 Sep 2018 18:18:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:38226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727262AbeI0WSU (ORCPT ); Thu, 27 Sep 2018 18:18:20 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (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 C1C2321571; Thu, 27 Sep 2018 15:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1538063965; bh=YFgO5gRTAqNkaDXgJXC1yTHMqd7i8Ti1YTrvVsjhZfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kIksGwe2IQNsXB+knj1DESoBmL4THu0fjEKPt3BPKXCcnZNXpkqMEDfmxdSbf6DvR 1kkDVDmsfOYWB2L4BCPB64XEY5H3RXUif4Z2jBxeySWV//X/uW5xbEcic6+u7g6+NJ FomJl+UyUAvo8EA4Pc7lGOIEmoONkJcG9ryLPeos= From: Masami Hiramatsu To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Tom Zanussi , Ravi Bangoria Subject: [RFC PATCH 1/5] tracing/uprobes: Add busy check when cleanup all uprobes Date: Fri, 28 Sep 2018 00:59:02 +0900 Message-Id: <153806394273.18458.15673352612088639322.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <153806391326.18458.3927382953014694981.stgit@devbox> References: <153806391326.18458.3927382953014694981.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a busy check loop in cleanup_all_probes() before trying to remove all events in uprobe_events as same as kprobe_events does. Without this change, writing null to uprobe_events will try to remove events but if one of them is enabled, it stopped there but some of events are already cleared. With this change, writing null to uprobe_events make sure all events are not enabled before removing events. So, it clears all events, or return an error (-EBUSY) with keeping all events. Signed-off-by: Masami Hiramatsu --- kernel/trace/trace_uprobe.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index 3a7c73c40007..a49583ece5fd 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -609,12 +609,19 @@ static int cleanup_all_probes(void) int ret = 0; mutex_lock(&uprobe_lock); + /* Ensure no probe is in use. */ + list_for_each_entry(tu, &uprobe_list, list) + if (trace_probe_is_enabled(&tu->tp)) { + ret = -EBUSY; + goto end; + } while (!list_empty(&uprobe_list)) { tu = list_entry(uprobe_list.next, struct trace_uprobe, list); ret = unregister_trace_uprobe(tu); if (ret) break; } +end: mutex_unlock(&uprobe_lock); return ret; }