From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DEC6C43461 for ; Mon, 14 Sep 2020 14:20:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41BEE206B2 for ; Mon, 14 Sep 2020 14:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600093240; bh=zJB1oW1vQK44avP9fjtJ8K9O0w9afCrN0uH+zbyIrNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HgH9wO0Z+wTm9IYTILp+F17BetDFvwitj8JohWEaZBZR5cW/kubi56ExgUTOxtCIL MTNjsjFEnWpPltDfxj2iCEK1DCXok9R+KyPD4E0AdPGv0N2wXLPFat3+/NK/orUb8O vUlWI2C4hR08JIPQIM1XakepGziFdSXkIhPp/16Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726804AbgINOUd (ORCPT ); Mon, 14 Sep 2020 10:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbgINOTK (ORCPT ); Mon, 14 Sep 2020 10:19:10 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 341EDC061788 for ; Mon, 14 Sep 2020 07:19:09 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id s65so10600164pgb.0 for ; Mon, 14 Sep 2020 07:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LzI4NVIZYMYJhFikPO81AHCmMRsACZLPQgfgpIaJP5Q=; b=Cl9StQfMBs+QDVIvjUFqxAfyNodAOEevNax0bqBPkbSIqVxwTCENulZxqgwM6SkbIP tjFxsEw0Q3T+sXJprFPi8pn/+01ZQujKD3ldqNcC1zmekTDe7TahBmTbx8zxkiEfbAMm wU5F01oRV7M8nDgdBlmI3GpcDjfEStx0FPRfHm0ukfxUmiNyHTXJFGjm7NrvOvHcbW3H GEs15o8VxTUOkDGA8AMvx10C205urKo7dQVIRzTp+8dMYT7N70MovInAbCohIYEIhiMB AGFugs7D+eP7xAF06PhLbQiMoQvkHLwFQfjpubqihmjLOFK7xHeNQTW5nMhyZwpse1xR h9eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=LzI4NVIZYMYJhFikPO81AHCmMRsACZLPQgfgpIaJP5Q=; b=hPvJID59hniZm3BDT3234VkfAzL6mU3NC0IQm1sMZLwRzDhvr4RySFCTk9sESDNP5X hEQh+e9wAZt1fsu4KuCkJIaZIgob4ACbE6wNTyfcEJ7bZWA3na+DYYXaP45e4VlC1GjB VVf5dpO1AoPF2GAZqMltCPm2zQXc74uG6yNR0JDyAlYsX6PqSc5trq+wDaABmQYhyceJ f0Y/RjsMZFMBXkOYVSr0AnzzmqKPtNucgng4M4Q3Se4DXGHZ/U003mIO7h2/TAmyJ0P6 04x537ZxtmCn1QmIglscLECttHMIYq+p3lxo9T0DHRiJJNf0+PMSJKcEbyVu4zqIpCdW vx2A== X-Gm-Message-State: AOAM532VrPIIeLlFFZUQFQenEAVBAjSgCZdFm/mOnobvxdldkMfQu2Bp cW6OsRD4v3U7MHIE5x+kJOs= X-Google-Smtp-Source: ABdhPJxi+sU18BZToj0Rl9jN8dA8C5/fwD2hsm1BlYcp4hSGFLO3Ei9asyiYXt85iIl+ppc8OGgB7A== X-Received: by 2002:a62:38ce:0:b029:138:838f:dd53 with SMTP id f197-20020a6238ce0000b0290138838fdd53mr12762209pfa.2.1600093148779; Mon, 14 Sep 2020 07:19:08 -0700 (PDT) Received: from balhae.roam.corp.google.com ([101.235.31.111]) by smtp.gmail.com with ESMTPSA id c3sm9209440pfn.23.2020.09.14.07.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 07:19:08 -0700 (PDT) From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , Mark Rutland , Alexander Shishkin , Stephane Eranian , LKML , Ian Rogers Subject: [PATCH 2/3] perf inject: Enter namespace when reading build-id Date: Mon, 14 Sep 2020 23:18:58 +0900 Message-Id: <20200914141859.332459-2-namhyung@kernel.org> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200914141859.332459-1-namhyung@kernel.org> References: <20200914141859.332459-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It should be in a proper mnt namespace when accessing the file. I think this had no problem since the build-id was actually read from map__load() -> dso__load() already. But I'd like to change it in the following commit. Signed-off-by: Namhyung Kim --- tools/perf/builtin-inject.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 59576877c67f..a2804d906d2a 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -23,6 +23,7 @@ #include "util/symbol.h" #include "util/synthetic-events.h" #include "util/thread.h" +#include "util/namespaces.h" #include #include @@ -419,16 +420,19 @@ static int perf_event__repipe_tracing_data(struct perf_session *session, static int dso__read_build_id(struct dso *dso) { + struct nscookie nsc; + if (dso->has_build_id) return 0; + nsinfo__mountns_enter(dso->nsinfo, &nsc); if (filename__read_build_id(dso->long_name, dso->build_id, sizeof(dso->build_id)) > 0) { dso->has_build_id = true; - return 0; } + nsinfo__mountns_exit(&nsc); - return -1; + return dso->has_build_id ? 0 : -1; } static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool, -- 2.28.0.618.gf4bc123cb7-goog