Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp858073imm; Wed, 25 Jul 2018 07:23:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdHHaTXTEW30jWJrrcRQN+QGxgJJ71he3E/4vDsP6CDK/UykVFPZZ3UvRYfOYualsUeHEDj X-Received: by 2002:a17:902:201:: with SMTP id 1-v6mr21567135plc.310.1532528589374; Wed, 25 Jul 2018 07:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532528589; cv=none; d=google.com; s=arc-20160816; b=X2fDH51q24muh1sJ60azHRv8HErG5s6BOfUlzKBcSPQFQm1LIppFQvWbQaVzQE4YhX IMKE0k1lkOl6rIBm4U18jqbBuRyhrDj7b+u9N44X+gCd8gyvd8tIOEoDmbG7e/jTpRe0 2RRM+Ry4a7yCTpMlMPDixadeiMHCwRXdeiKkLtm8xsl89VA2Qm1r3iLNvrsNm2dmnGbk yGV2G59++zjI78ZDJDLuUZzWGYtOlzjWXxgXVAgp2Ax9qn/ra74a7WuPolryF3ILqRXQ iGo1BhoK88J/aXBWPzcJf1FRuMLf63zBEoTONob5kwRnZ/vbB4gfUn7G3lUcr51/z7pP 4WKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=QKko7RqsY2e7/ne1tmjTfY2T2wzjqgss+qybJ90dVyc=; b=ZFLj7E3L+VgzC2OCTuNip5yhXW32z3oiOOItPhd34Exsvy8JrjlGV54YvlxY/Sc0k6 LtaP/WfcrMAK+KwJ1bDZ46CYiFMVeWvWxggyxhnjdcfXe1RVCD+ME7HoQ07GdXH+9C4N 308/pvAiSnWT4KnCtBCTfISxtJiMNs4ZzfizrA8WwWRsdgW4I9IZaYN4dmi8gJtqeHY5 aNRP1Xto3eoGcVtS6nIKpLql5i+UxtnO/DplVoE9n00Fnt6S/0lGSB/f/B75BTVPNr0D GqrmZQT+uQyn7DxI6IqJ7gIf1yC1CWrU/uQdDqIyAbweeWKHBKnEmbiK0BXFTqAYTEAH 8/BQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o123-v6si16213859pfg.5.2018.07.25.07.22.54; Wed, 25 Jul 2018 07:23:09 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729367AbeGYPcz (ORCPT + 99 others); Wed, 25 Jul 2018 11:32:55 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46238 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727881AbeGYPcy (ORCPT ); Wed, 25 Jul 2018 11:32:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DBD8E40216E1; Wed, 25 Jul 2018 14:21:00 +0000 (UTC) Received: from shodan.usersys.redhat.com (unknown [10.43.17.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFFC62026D68; Wed, 25 Jul 2018 14:21:00 +0000 (UTC) Received: by shodan.usersys.redhat.com (Postfix, from userid 1000) id CBB392C075D; Wed, 25 Jul 2018 16:20:59 +0200 (CEST) From: Artem Savkov To: Steven Rostedt , Masami Hiramatsu Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Josh Poimboeuf , Artem Savkov Subject: [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure Date: Wed, 25 Jul 2018 16:20:38 +0200 Message-Id: <20180725142038.4765-1-asavkov@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 25 Jul 2018 14:21:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 25 Jul 2018 14:21:00 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'asavkov@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Artem Savkov --- kernel/trace/trace_kprobe.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 21f718472942..27ace4513c43 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -400,11 +400,10 @@ static struct trace_kprobe *find_trace_kprobe(const char *event, static int enable_trace_kprobe(struct trace_kprobe *tk, struct trace_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; @@ -424,6 +423,16 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file) 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; } -- 2.13.6