Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp836981rwb; Mon, 26 Sep 2022 06:31:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4uG2v5v/S7Y+99gDZkz8VhVyqfc/yCNqRtumKx2v/jBIduYr8cGJoadSyA+peD5G63YF3j X-Received: by 2002:a05:6402:3550:b0:451:473a:5ca3 with SMTP id f16-20020a056402355000b00451473a5ca3mr22381251edd.48.1664199101392; Mon, 26 Sep 2022 06:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664199101; cv=none; d=google.com; s=arc-20160816; b=SA8UM8wqUG54N1aS+hEdBZkR94Gk9seBRv6JICsYzfJNUX0q3Zl9T8bH8UV0KuCFZ+ txy4rMMYWZ8PRAzeeM2C0OfnS6Q18VcQ2UNQy5Wk5k31W5Rm0mMpVDc702Rrx/+BAas0 KcL2zbAHH0fcqvGoK6HPtbATVYC9ECNLg9y0ClcQS+NMkxHN4rXisZNRMm/Ywi9CU5vu 3S6YijVW5T/8O+DE2/2hssexbPUOc3LtG6Edr5ue/kO+rEMZl3FvmqHlJmAXsg2Lb0BA wtcz+hX/lV0OP7kPn/FpntxGJXnvJ4pHJeYwOiNTHOlkfwG4hnDHMEcLNdEsxpE9uaFL UAGw== 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=gQKnhc76oCmitfG3YSyU9HBvgChkLVqR2Oe7j/KhZw0=; b=E45OelzPnktiCle6yNm4xMnycjj5ak1XDbtTsjvYMeoWGiAtR3jsK2vj2Yp7VRa2li 99W72af1NXDNe5Ognx3h8kh48XnTXiCSZWozKa+g6WMGM4xd26D1Y9EgRb5IBlLcmyLB BUqKHGXXO7DifaQ1RTUao60FUR09Vb2aEJBLJkGsJFpUuHTZeZw8bg7ThYFZaNm82ETd IrlBrtS9bTdDMpAVn3FgotRZPAiA4fZmSiyeiTlSqEqQ7iyrSq559z8DDX5cjr+tIiai w7r1qAVRqmy+R5+SBoJuWB9lLRRkF5BYaYN74ldQw+d32VP6Jyg/qyZcyubaMl2P3sjg 7MCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Usr4bFJU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wg7-20020a17090705c700b00782525053dbsi15207947ejb.699.2022.09.26.06.31.13; Mon, 26 Sep 2022 06:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Usr4bFJU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S236518AbiIZMX7 (ORCPT + 99 others); Mon, 26 Sep 2022 08:23:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239556AbiIZMXi (ORCPT ); Mon, 26 Sep 2022 08:23:38 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05EB08A1DE; Mon, 26 Sep 2022 04:05:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id A2552CE1117; Mon, 26 Sep 2022 10:48:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84783C433D6; Mon, 26 Sep 2022 10:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664189323; bh=iQBts69Xg4uRZG7l2hp4cSGamepujS260GBRhpeKnlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Usr4bFJUtRg+rESsU6WdhYe6dsAsE0Zf1x6vltQKpY1d7aHDFN/fXaZDkpK626BLW i/4rYy7F+dayaIGrKe/csmWUWmSdA9xjDF7ZEnygvCJ056Xn0JLqBCxeGWJfTiPjXh qoCWhyZRy4qLKHpcAaV6VbtoBbNI4UXFlz7/EhOA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namhyung Kim , Adrian Hunter , Ian Rogers , Jiri Olsa , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.19 149/207] perf tools: Honor namespace when synthesizing build-ids Date: Mon, 26 Sep 2022 12:12:18 +0200 Message-Id: <20220926100813.321988454@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100806.522017616@linuxfoundation.org> References: <20220926100806.522017616@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim [ Upstream commit 999e4eaa4b3691acf85d094836260ec4b66c74fd ] It needs to enter the namespace before reading a file. Fixes: 4183a8d70a288627 ("perf tools: Allow synthesizing the build id for kernel/modules/tasks in PERF_RECORD_MMAP2") Signed-off-by: Namhyung Kim Cc: Adrian Hunter Cc: Ian Rogers Cc: Jiri Olsa Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20220920222822.2171056-1-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/synthetic-events.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c index 84d17bd4efae..64e273b2b1b2 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -367,13 +367,24 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event, bool is_kernel) { struct build_id bid; + struct nsinfo *nsi; + struct nscookie nc; int rc; - if (is_kernel) + if (is_kernel) { rc = sysfs__read_build_id("/sys/kernel/notes", &bid); - else - rc = filename__read_build_id(event->filename, &bid) > 0 ? 0 : -1; + goto out; + } + + nsi = nsinfo__new(event->pid); + nsinfo__mountns_enter(nsi, &nc); + rc = filename__read_build_id(event->filename, &bid) > 0 ? 0 : -1; + + nsinfo__mountns_exit(&nc); + nsinfo__put(nsi); + +out: if (rc == 0) { memcpy(event->build_id, bid.data, sizeof(bid.data)); event->build_id_size = (u8) bid.size; -- 2.35.1