Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3679416pxv; Mon, 26 Jul 2021 09:14:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAVZL1jT+lUZlLokkw/VClTUQpdghmNanhGtsXMlFMWYhZi+rdBGe4ic8z7Tra6B0ltZeU X-Received: by 2002:a05:6402:60e:: with SMTP id n14mr22524700edv.363.1627316086917; Mon, 26 Jul 2021 09:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627316086; cv=none; d=google.com; s=arc-20160816; b=mHMX8z36O9dKqj8hB/zD1/drQh9PPO8CxqQMJ/lppZpqeeMEzqNqe45g5JOboR8pNi y+PWyzbbs8dWVKTEpOWi5nvglex90x7CAO+YkqXokc45SGPpFMdQ8wXLgCqg93LUJpr+ O3GIV59aKUJa/p55uiDjJqzFWWDJkFWKyCN7aXn9w7SDCnahh/hSw2MFQRfxyk4NhdEc kJCM/tgDWhUlMCtTSwdTg23Gkw2PhDlv+PvYGsd3mwtgJtP5cwlXT8K1pwe5uPo31J3m ayquhHtD3TB1sH3cDBXQ5nni+3+17eSCKer6F4AI/yQ6+np4PLXbtbCxhucw8Dselyst 46lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/tFOjjACITlliqECF2DXsvYsdb1cakWT4tM1L/QSUkQ=; b=U8R6qcULs/JKOlYTPJW1dHku7kPDBmzWq+QrFAW4tS0PFrAqRmnorYabCJufFMczs5 qwMI0UXD4+BUDN4JBIE1vL8eAYoSg9RXajFfpdhn2COnIsl9UTaoMHnigD2s/8cqXQu1 HMy/X58RLCUlmBwVRg1R2P9JghWk6hElU9O5RRS2pWc0pKtUXt8QgzRmsIbx9TkXaO+P NQXZiFJZ2T98oR/L1BwGZNYN1SrWTwuyVW17/tbqa93kFNNZV52SeQ2NWsuTZ6nElzl+ H2MQCBafbRzp1d1vsyDVe4bvDmx2rXC42c4pVXJ/G8IEOGd+q6ZBGLuxVpYS+8IhjHk3 sPaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ctPn/Ha8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si281695ejy.231.2021.07.26.09.14.19; Mon, 26 Jul 2021 09:14:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ctPn/Ha8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237924AbhGZP33 (ORCPT + 99 others); Mon, 26 Jul 2021 11:29:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:57100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235849AbhGZPRD (ORCPT ); Mon, 26 Jul 2021 11:17:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C6C306056C; Mon, 26 Jul 2021 15:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315051; bh=U9yyxX2jky8jJdfnvCW3J7wpNnEbHowqzpCpgdgH1QI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ctPn/Ha8ZgXhj6UeicRRHdxwMSJnu8F/y3EbSv2Ia72QBNqF7epwnUSzaW2unbAE3 yCLtGwKVw1Uj+u1L4vd2GPDO1NsnFVBsYwJq5SF8myIkTkUDTNs8meTlmc3CoYCOin RTYuQRmCoPdFXx+olULnetOB728xmvRrxQYmF2zI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riccardo Mancini , Ian Rogers , Jiri Olsa , Krister Johansen , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 021/108] perf probe: Fix dso->nsinfo refcounting Date: Mon, 26 Jul 2021 17:38:22 +0200 Message-Id: <20210726153832.374187674@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Riccardo Mancini [ Upstream commit dedeb4be203b382ba7245d13079bc3b0f6d40c65 ] ASan reports a memory leak of nsinfo during the execution of: # perf test "31: Lookup mmap thread". The leak is caused by a refcounted variable being replaced without dropping the refcount. This patch makes sure that the refcnt of nsinfo is decreased whenever a refcounted variable is replaced with a new value. Signed-off-by: Riccardo Mancini Fixes: 544abd44c7064c8a ("perf probe: Allow placing uprobes in alternate namespaces.") Cc: Ian Rogers Cc: Jiri Olsa Cc: Krister Johansen Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/55223bc8821b34ccb01f92ef1401c02b6a32e61f.1626343282.git.rickyman7@gmail.com [ Split from a larger patch ] Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/probe-event.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index a5cb1a3a1064..6357ac508ad1 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -175,8 +175,10 @@ struct map *get_target_map(const char *target, struct nsinfo *nsi, bool user) struct map *map; map = dso__new_map(target); - if (map && map->dso) + if (map && map->dso) { + nsinfo__put(map->dso->nsinfo); map->dso->nsinfo = nsinfo__get(nsi); + } return map; } else { return kernel_get_module_map(target); -- 2.30.2