Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2076900ybp; Thu, 10 Oct 2019 01:46:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqz796WQCmsyeVTScDrUSdCtEl5vniqtFxu61WSpfEZBrLyu9vN4zkrsQAyzmIkQb1NGc5xX X-Received: by 2002:a50:aca5:: with SMTP id x34mr7014032edc.130.1570697178741; Thu, 10 Oct 2019 01:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697178; cv=none; d=google.com; s=arc-20160816; b=K2AXvkbaDcUaLn73ExwWg0iY+nSg8emz66XBYJQ4uqHS4npeoLJYPDTaPOf01TSp7I 3iYnGYUy63chT7m4PCRe+8pQ5152tFaOVVxgRdWQIK5Iumh/UBDXUVlk3cQRpKb2NU4H sSTpZNl5udaB/TkfWxgACfcgvFGGuYdX3KJc3+4FEceeWD4mUKAKsA4/0Phpq1tXeXpM aZdkrS4m69yvGX3s9N8jsZ+qurApHjcMbWo/sqKMNpTzyVqElHqvsNuOlugURy1NkLcS TOQs0WpoSDD+BXHZJdPEHXi3ZPwBSqytpqi6LtJCZOeg2LS9rJzcizE0FXkmMscy/4YC P8Gg== 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=XtWOWPJtya2OPd/s64xZSOEwENs/UXpm0zhZ9S+7vRY=; b=EkYfwdKZpYmpeMjYvueYSXdsCy8fEP8NXSmT5MWanuernIrRRyuX8LUtpfM3CIZNsH 3+QslJxxfykhdFKXLPp7AkljhRv7w/IOfzezDwXdUz7eIgviItLoARYtSz2D7TtdrtmW hLFRIk6CJQMgd4oXGzidCALl8X2Vib6MxBf5Rn988FZ10T2n2b+3Ju0wh7hWd7+OXYch GKBjU5pGUkdp4rWNzshIZhJro49pNr//FQKBbqozF/r8vCPXK9VWihzBhuGjo4kdiVi7 bolTg+OkmTrazdyfrUdI+Xo51WsO7yjCMb+lDvY5V30czO/Qp/yc/ESmbeQIdvmtJlPd slSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VXmdMV5T; 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 b56si2918451edb.418.2019.10.10.01.45.55; Thu, 10 Oct 2019 01:46:18 -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; dkim=pass header.i=@kernel.org header.s=default header.b=VXmdMV5T; 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 S2388512AbfJJImR (ORCPT + 99 others); Thu, 10 Oct 2019 04:42:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:46780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388505AbfJJImO (ORCPT ); Thu, 10 Oct 2019 04:42:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 5564921A4C; Thu, 10 Oct 2019 08:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696933; bh=NuHhHXw4QZBdglT0kxOOBHpNOn1XLOOMc9cyecLOYBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VXmdMV5T0Blg5SknT5F4OCZkGgelj1rw0yKIcvs1uExynIJmYuh2bHAElvy9sLAjq PG0whQ2LKffoa9Ri4IaeEdKNNbHlQwA9ZISjGTDMOi495Fj0r33h8dXVy7OUCH6tRj qCPB+DyJ1EKt91gBFVnt/8fd5ddPYAQZwjeZ3ZTk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Wang Nan , Sasha Levin Subject: [PATCH 5.3 106/148] perf probe: Fix to clear tev->nargs in clear_probe_trace_event() Date: Thu, 10 Oct 2019 10:36:07 +0200 Message-Id: <20191010083617.608325655@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit 9e6124d9d635957b56717f85219a88701617253f ] Since add_probe_trace_event() can reuse tf->tevs[i] after calling clear_probe_trace_event(), this can make perf-probe crash if the 1st attempt of probe event finding fails to find an event argument, and the 2nd attempt fails to find probe point. E.g. $ perf probe -D "task_pid_nr tsk" Failed to find 'tsk' in this function. Failed to get entry address of warn_bad_vsyscall Segmentation fault (core dumped) Committer testing: After the patch: $ perf probe -D "task_pid_nr tsk" Failed to find 'tsk' in this function. Failed to get entry address of warn_bad_vsyscall Failed to get entry address of signal_fault Failed to get entry address of show_signal Failed to get entry address of umip_printk Failed to get entry address of __bad_area_nosemaphore Failed to get entry address of sock_set_timeout Failed to get entry address of tcp_recvmsg Probe point 'task_pid_nr' not found. Error: Failed to add events. $ Fixes: 092b1f0b5f9f ("perf probe: Clear probe_trace_event when add_probe_trace_event() fails") Signed-off-by: Masami Hiramatsu Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lore.kernel.org/lkml/156856587999.25775.5145779959474477595.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/probe-event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 8394d48f8b32e..3355c445abedf 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -2329,6 +2329,7 @@ void clear_probe_trace_event(struct probe_trace_event *tev) } } zfree(&tev->args); + tev->nargs = 0; } struct kprobe_blacklist_node { -- 2.20.1