Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3327456imu; Sun, 11 Nov 2018 12:27:45 -0800 (PST) X-Google-Smtp-Source: AJdET5fZ/P3hdsgkdn3MW1OfSLRWvQc7NRk+e5W7e0PM9cAXrbu5FsgE0is3O5G/c/t6nntVTxMr X-Received: by 2002:a63:235f:: with SMTP id u31mr14927667pgm.122.1541968065147; Sun, 11 Nov 2018 12:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968065; cv=none; d=google.com; s=arc-20160816; b=pO6mmMVbnxpl0KEAlP4Zwt1AQWhDV1gUVw6GX2sSk4Qa81NYo88h1hniZmT9BVehYG PTqiSxpeycsbahzJp/ibc/lwIDQkjY0nphPaelt63wsUOPws0sgrK+j+AkEaRjr+fazk pkJIyqcTcfugYLMc3dhUaDAmHBURNky+g+GD8Qi0bjwndd05DXngMkF3KLtUE33+P+v0 yGMNdxRSgkdd8UEKOEl7mdHj0NB08Ek/lwuq2Y8BrfB61AiYB+LXr10q9759pHAaPnY2 LQ/RdmFCDTrfTWAd7ToGQeOe0WuWwci2HXmQ389pQEMgjuOn4zUfslFH/2q930Zt986n kZXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=x+scZpnkZW4DNJtCXsWiMvttNEDBEzsL4IfBJT4GBoE=; b=ft4NmcW1UQUaKDCTInDX9oAdEKoZ4i2+m9pmfen5QJXTEBuXaAehjVhtLylpyyeuAv 8XTEroZtUVBigmltQza3MgviZkztXtqMliq54mJyk+UGa4C63ZxRSRJjcDNrG1E22MfW S8agdks0hmW16/PlApz4wEwvAcQmIRaIOBkKNCu7JyjEfVsi2/mntHRal17OCHlW6Slz ptPNeEV1L95RfBuS3kadWQbzPAef2sP3USBtyQwNty3phLSuaY2To5vsbrNU3Dr2rVvZ Xl4HSoXGCaRYCxgaZxtHJ3wn3zKVfT3c6sFMnWjmiP58+i0LHYYeJnsD+Uxo+Tt5gujP 8W0w== ARC-Authentication-Results: i=1; mx.google.com; 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 w6-v6si15886795pfn.212.2018.11.11.12.27.30; Sun, 11 Nov 2018 12:27:45 -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; 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 S1731611AbeKLGQl (ORCPT + 99 others); Mon, 12 Nov 2018 01:16:41 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50812 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730598AbeKLFs0 (ORCPT ); Mon, 12 Nov 2018 00:48:26 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsl-0000lK-Cf; Sun, 11 Nov 2018 19:58:55 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsY-0001mf-Ce; Sun, 11 Nov 2018 19:58:42 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Masami Hiramatsu" , "Steven Rostedt (VMware)" , "Artem Savkov" , "Ingo Molnar" , "Josh Poimboeuf" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 295/366] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Artem Savkov commit 57ea2a34adf40f3a6e88409aafcf803b8945619a upstream. If enable_trace_kprobe fails to enable the probe in enable_k(ret)probe it returns an error, but does not unset the tp flags it set previously. This results in a probe being considered enabled and failures like being unable to remove the probe through kprobe_events file since probes_open() expects every probe to be disabled. Link: http://lkml.kernel.org/r/20180725102826.8300-1-asavkov@redhat.com Link: http://lkml.kernel.org/r/20180725142038.4765-1-asavkov@redhat.com Cc: Ingo Molnar Fixes: 41a7dd420c57 ("tracing/kprobes: Support ftrace_event_file base multibuffer") Acked-by: Masami Hiramatsu Reviewed-by: Josh Poimboeuf Signed-off-by: Artem Savkov Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Ben Hutchings --- kernel/trace/trace_kprobe.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -361,11 +361,10 @@ static struct trace_kprobe *find_trace_k static int enable_trace_kprobe(struct trace_kprobe *tk, struct ftrace_event_file *file) { + struct event_file_link *link; int ret = 0; if (file) { - struct event_file_link *link; - link = kmalloc(sizeof(*link), GFP_KERNEL); if (!link) { ret = -ENOMEM; @@ -385,6 +384,16 @@ enable_trace_kprobe(struct trace_kprobe else ret = enable_kprobe(&tk->rp.kp); } + + if (ret) { + if (file) { + list_del_rcu(&link->list); + kfree(link); + tk->tp.flags &= ~TP_FLAG_TRACE; + } else { + tk->tp.flags &= ~TP_FLAG_PROFILE; + } + } out: return ret; }