Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp630053imm; Wed, 25 Jul 2018 03:29:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdQ/QRSUPYA03u4dkn273Qo7UrGvh7U9AHF987ft/Eu9Srffz8PEtMh1VD/5RYdo9pDs0SW X-Received: by 2002:a65:5a01:: with SMTP id y1-v6mr19839807pgs.125.1532514591083; Wed, 25 Jul 2018 03:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532514591; cv=none; d=google.com; s=arc-20160816; b=RjyamAvgmhYN+xWKL9zulEbY/hL/t7XQ1ca6NkFcqnOAQrbOAYs767NZK8nVndzEew p9YyU9FQOEl++rnpcl8C+Efsl66+KLFB2TpJb6yyrEypWJcVd/PEPevuPRXDD+I12bSS sSo7aAK1ZtuiR3jnhbIea7y0C1SrYpbj8GqbJamaAg3d5M3Pm6eBFYZKnHlfahEkKoV4 nHYeo6GNanin0Y3luKL0RoRRIy0EmooeJPQ+lgig8bs0QSsnKvltGF9ODs/DS1eQTW+V Gv+hYYdSka2nsXA8N2dSBc2EmrO9G0QWFFbKCuGxnKdV42e6pbELjDSdxAd1j5g4h+j9 Ah8w== 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=OPqhKeCke9KhZn4rq3zEAwCWmI1SqeG4GaAeblRWHP0=; b=rHVHb4ch0kfv9GCIU04fEHHrZWEXOlyHyVI8WsIq4lBwXagqa6rKWwUnRKOB6O5j/c dA7BpOPWlj/35dFYIqVASDaTzQnKj+5YN5EGjKEV+MOsXDpVPtwf5Hpz14CQtYQyqUIB pbIB7Qeq8Sfng1B7cWLihg0CtU4kjG9JmdOzKwJvjuMBQqxhyLMYNHnJM+O5IicSljvP wqdkuAbVNWjevhm8M4Yzr9doRT0UBM37HzbsLB0D15lgMDCZUXcavFjsql7NCrZGpetU rTghVW1IRd1PJH/xF2AL7UHcdFc8eFh60lvA1Sh/+OIjdDtQVxakOXSnazdGZhQSf8Bb BT8A== 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 v129-v6si14164544pfv.278.2018.07.25.03.29.36; Wed, 25 Jul 2018 03:29:51 -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 S1728817AbeGYLjs (ORCPT + 99 others); Wed, 25 Jul 2018 07:39:48 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41142 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728527AbeGYLjs (ORCPT ); Wed, 25 Jul 2018 07:39:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 79A5068802; Wed, 25 Jul 2018 10:28:44 +0000 (UTC) Received: from shodan.usersys.redhat.com (unknown [10.43.17.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 503861684A; Wed, 25 Jul 2018 10:28:44 +0000 (UTC) Received: by shodan.usersys.redhat.com (Postfix, from userid 1000) id 7A43D2C075D; Wed, 25 Jul 2018 12:28:43 +0200 (CEST) From: Artem Savkov To: Steven Rostedt , Ingo Molnar Cc: linux-kernel@vger.kernel.org, Josh Poimboeuf , Artem Savkov Subject: [PATCH] kprobes: fix trace_probe flags in enable_trace_kprobe Date: Wed, 25 Jul 2018 12:28:26 +0200 Message-Id: <20180725102826.8300-1-asavkov@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 25 Jul 2018 10:28:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 25 Jul 2018 10:28:44 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 previosly. 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..fb887ced5056 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(&link->list); + kfree(link); + tk->tp.flags &= ~TP_FLAG_TRACE; + } else { + tk->tp.flags &= ~TP_FLAG_PROFILE; + } + } out: return ret; } -- 2.13.6