Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp310837imu; Mon, 5 Nov 2018 01:01:32 -0800 (PST) X-Google-Smtp-Source: AJdET5ca8LwaZNEVmcARglItne/78nYqkEopNXnY3oE14w2nzJigDegbHbbw4Fggc5jUYs6i/0Er X-Received: by 2002:aa7:80cd:: with SMTP id a13-v6mr21018164pfn.86.1541408492522; Mon, 05 Nov 2018 01:01:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541408492; cv=none; d=google.com; s=arc-20160816; b=OljOQzaJ/BhpoizC3eRsFMULVCyOKLPHy6bw4kC92Eb2hUpbjtmg0wUsLyAiY7xecs /2RzlByYcUs+zNxEbYw4VMLJLno9kzA8z9DO1QinLrYNyjqKwESb0dxV8Lbc/ZhGFYYd F7Aqgo4vHsiQmH2VDaBKOLxLyTsURowpcgqPA2jMypr01vHGAn164DjBipaT7hxldvvo +uPrnOoKrp6/bD2nzNvR40KT4nAToSqByrC0sQOXUIh4eIgGSk3tLAuOdiBOEr3OTik5 zcfjvc1WZhtZZLZh7028D/9fBdJCdPiIkSRqfbGLYTCCudZTWJ/K0dhUPkzyOaNPuhSW Zt5A== 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=qzS3tCJdZLoOYktv1cBfsY1/sLgf4Tb7wDr0/EpkgRM=; b=ErmuXqET8sj/+SHbWJ7TFD4HNVFTzvFwhqZdolD+GN04PEL5JnkZQhPTosjkwwPyLB juCnTqssMe+ihISMEfCtvqiI32ztgmcDbrf46S8D6Se2d5XjuzO6esIyMq0zidDDwd7o GNiGIWsCGs7rTau9J397zmAjmoqh7bSIcy/hudB1EA1Ke+azNqDnDF6//Ks2ho1NHQDx 2wWdMcmMIIfheVcTOfBZaLOD2jMbe3XV2oyuRJpAV/AYJV4L32mxv4n3CEWw3FAWL9BD uL80+C5U/7HhEohq37EUPM/sEzIwJN9e+QwSL6DS8Jt+KMkOpxhKJcclv/4XUZUWadTM zh4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dX4jRc4T; 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 cd9-v6si3125280plb.231.2018.11.05.01.01.16; Mon, 05 Nov 2018 01:01:32 -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=dX4jRc4T; 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 S1727271AbeKESTS (ORCPT + 99 others); Mon, 5 Nov 2018 13:19:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:49370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbeKESTR (ORCPT ); Mon, 5 Nov 2018 13:19:17 -0500 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 A37F320862; Mon, 5 Nov 2018 09:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541408438; bh=UoWWfEvbRM0oO+cNrgEn3kjbwCO6FsRAuztRWoTbi0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dX4jRc4TmbPtLzBN6IZ4bLBnoSHUgSURnc+N6fStNZtR48+jwOoCEPH/fb+65qnhe VPpLJkREbXeuIR0kBpWLEAeQqqOTjt3GPZ6kIiyw8gYRGj1UwngfTAuDbiH2xLjHnE 2eVucgaRS/VRen14DKUC6Zx9A55tOZKuGfEl2SXg= From: Masami Hiramatsu To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Tom Zanussi , Ravi Bangoria Subject: [PATCH v2 01/12] tracing/uprobes: Add busy check when cleanup all uprobes Date: Mon, 5 Nov 2018 18:00:15 +0900 Message-Id: <154140841557.17322.12653952888762532401.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <154140838606.17322.15294184388075458777.stgit@devbox> References: <154140838606.17322.15294184388075458777.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 31ea48eceda1..b708e4ff7ea7 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -587,12 +587,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; }