Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1149013imm; Wed, 1 Aug 2018 11:00:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcNFu97qDAI6BE5ck37vzfjjETaVo67/1E2+z92con/R6G38PxdgtLdKDo/PHH7iG3oxmOf X-Received: by 2002:a63:62c4:: with SMTP id w187-v6mr25419644pgb.55.1533146441592; Wed, 01 Aug 2018 11:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146441; cv=none; d=google.com; s=arc-20160816; b=YI4FR4qmrdiHrvYsQm+b3nS73/UsBa6NcBAoIEYg/sqFU75/YsZNMnLCpM4x06foUa 76Ycv1HlDuAB44mIuHWpdYPDFlGNMW50r2e0epSYS1BXhBTV3a/+w2ig6PQKHkUXBHzJ xqd2L+42fXXIsr3RA//KqAzjQFyI2gl6nOAO1FHQrwfVUhet/qQHx/NSyPBBKEKP9ROu 1Ydq+I+RUOA8A6m5WSQhmFbiqLoz8CJ2J3mDYnL/cPTd5kZuuvZW4Nj8GpgzDR5pU1kV bevaDFwkYeygWFpEhvgr7k4ROecOXFKCD7tKFBaU08KemH+SVMLKiwBxdMS/ge0Hjkd0 yAEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8w8fW0W6UMUkGUMP2u3PvDdbmg/tGY2GdeLO4/XusXQ=; b=Fbr+g/VOuRCqAjsFjZ5haBY0bM0RLBZPc2GR3M6uAUGS3eEdCr/of20TtcDVx4N8li oUqzJGMQHSfhdGtewwP6IJyE5WvSZJpeLATvZdaYpSYnZEsBMpVOIJXiQvRO4kGdSOcX pIlRASk3o2uPRGUdIw6ZD32UsnaDPUj7P9qfzLDPCPicKcgEzCGOLoZYkDMxy92GS/cd T7Z0nertLZapft116xV1LaLsNJLmB/CEFs1uLbfKuwNPBpmncS/ejLZrwS9lj2jgQgfk uQxVlp/tCJ3GK0nM5h9zZobp8w5YwA2MUuS+qJtONNpxtHQritXjWAh/QvG4xFJcybTu gU1w== 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 d6-v6si16679222pgh.569.2018.08.01.11.00.27; Wed, 01 Aug 2018 11:00:41 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405937AbeHATIj (ORCPT + 99 others); Wed, 1 Aug 2018 15:08:39 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50080 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405714AbeHATIh (ORCPT ); Wed, 1 Aug 2018 15:08:37 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E3AE51335; Wed, 1 Aug 2018 17:12:10 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , Masami Hiramatsu , Josh Poimboeuf , Artem Savkov , "Steven Rostedt (VMware)" Subject: [PATCH 4.14 016/246] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure Date: Wed, 1 Aug 2018 18:48:46 +0200 Message-Id: <20180801165012.479355149@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable 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 Cc: stable@vger.kernel.org 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: Greg Kroah-Hartman --- 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 @@ -376,11 +376,10 @@ static struct trace_kprobe *find_trace_k 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; @@ -400,6 +399,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; }