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=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 72D2CC2D0E4 for ; Thu, 12 Nov 2020 22:54:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C70CF20A8B for ; Thu, 12 Nov 2020 22:54:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=dxuuu.xyz header.i=@dxuuu.xyz header.b="PpFzMzXH"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ee0TLRkp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726102AbgKLWyS (ORCPT ); Thu, 12 Nov 2020 17:54:18 -0500 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:40959 "EHLO wout5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725973AbgKLWyS (ORCPT ); Thu, 12 Nov 2020 17:54:18 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 38F103BA; Thu, 12 Nov 2020 17:54:17 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 12 Nov 2020 17:54:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h= mime-version:content-transfer-encoding:content-type:cc:to :subject:from:date:message-id; s=fm2; bh=hR/B1/mksMg4nf29wakGk+i VZrvBuyXfFOqVP/Ac498=; b=PpFzMzXHxp5c6435BPLh0Op1Z51473xLnoz/1D4 PBzKXLL1Trl/iGVvSS5hQQhbohhoNbjP8WrhMQDwSkOb6IkWc5nSrSC+w2olGuG0 p684008oVCResM6N2owZJ6AQaEfREjD0HTKhe0ADsHz47hfc4mCBHdcgQsqa9JxL jags1GBklYdLwgDCn1ikmc7/NaWejeKDQB5ZkieowKoTgBDb1r89CRzAdeIRug2f wFy46wHhTJitMf5xo5mLJqU1s+qcbo5avNVjcG6kQ9JhB/xqt5xOYw9NNWviPsXd d6gNNYlVTqFb/uhD3mQawNCA3QNwMfALnPo1saeGR8UBqBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=hR/B1/ mksMg4nf29wakGk+iVZrvBuyXfFOqVP/Ac498=; b=ee0TLRkp2fG616K+S4BtkY QE2gR2tMJSRWl+4CaUwucfcT+GnwlwzpNF7wlSLq6aKVvzHNuLA5BMw9xXfWiSSP UgZdGSqJloZs0mNuEBBB4bbCTzlOD6NvB0xguyi/ElSs1bK47O2xFezLPBxbdLO/ otbXwIdMv8rwVZ7vqxlJdMPQAiC4Qg1SflhlW/6ppfXJm1gOu/82pv93FqX0v1Hx jza7fwyTffAlejbtqDMmXTt2tdlTK/g+bX0IYzdv1alqNQLJUpNtu0QwM3QF/NsN HKuyA1usrr6nx1dAGiMGF6/KbtKAl0Yx0gIzFIzJY9qG9tsuN/0njyL8mZpAr5aA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvgedgtdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpegggf gtvffuhfffkfesthhqredttddtjeenucfhrhhomhepfdffrghnihgvlhcuighufdcuoegu gihusegugihuuhhurdighiiiqeenucggtffrrghtthgvrhhnpeeiffehfeekgfeitdehff euhfekgeelfeduueejveegueejtefhteetuefhgefhteenucfkphepieelrddukedurddu tdehrdeigeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpegugihusegugihuuhhurdighiii X-ME-Proxy: Received: from localhost (c-69-181-105-64.hsd1.ca.comcast.net [69.181.105.64]) by mail.messagingengine.com (Postfix) with ESMTPA id EBBF5328005E; Thu, 12 Nov 2020 17:54:15 -0500 (EST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Cc: , , , To: Subject: Extending bpf_get_ns_current_pid_tgid() From: "Daniel Xu" Date: Thu, 12 Nov 2020 14:20:35 -0800 Message-Id: Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Hi, I'm looking at the current implementation of bpf_get_ns_current_pid_tgid() and the helper seems to be a bit overly restricting to me. Specifically the following line: if (!ns_match(&pidns->ns, (dev_t)dev, ino)) goto clear; Why bail if the inode # does not match? IIUC from the old discussions, it was b/c in the future pidns files might belong to different devices. It's not clear to me (possibly b/c I'm missing something) why the inode has to match as well. Would it be possible to instead have the helper return the pid/tgid of the current task as viewed _from_ the `dev`/`ino` pidns? If the current task is hidden from the `dev`/`ino` pidns, then return -ENOENT. The use case is for bpftrace symbolize stacks when run inside a container. For example: (in-container)# bpftrace -e 'profile:hz:99 { print(ustack) }' This currently does not work b/c bpftrace will generate a prog that gets the root pidns pid, pack it with the stackid, and pass it up to userspace. But b/c bpftrace is running inside the container, the root pidns pid is invalid and symbolization fails. What would be nice is if bpftrace could generate a prog that gets the current pid as viewed from bpftrace's pidns. Then symbolization would work. Thanks, Daniel