BPF List
 help / color / mirror / Atom feed
From: Carlos Neira <cneirabustos@gmail.com>
To: Yonghong Song <yhs@fb.com>
Cc: Blaise Sanouillet <blez@fb.com>, Daniel Xu <dxu@dxuuu.xyz>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"ebiederm@xmission.com" <ebiederm@xmission.com>
Subject: Re: Extending bpf_get_ns_current_pid_tgid()
Date: Wed, 16 Jun 2021 17:44:38 -0400	[thread overview]
Message-ID: <8b656897-8241-daed-861d-d33beff7934f@gmail.com> (raw)
In-Reply-To: <c176cb4f-26d9-28b3-3f6e-628c1a5fa800@fb.com>

On 6/16/21 1:02 PM, Yonghong Song wrote:
> 
> 
> On 6/15/21 6:08 PM, carlos antonio neira bustos wrote:
>> I'm resuming work on this and would like to know your opinion and 
>> concerns about the following proposal:
>>
>> - Add  s_dev from  nsfs to ns_common, so now ns_common will have inode 
>> and device to identify the namespace, as in the future namespaces will 
>> need to match against ino and device.
>>
>> - That will allow us to remove the call to ns_match on because the 
>> values checked are now present in ns_common (ino and dev_t).
> 
> I understand its benefit but I am not 100% sure whether adding s_dev to 
> ns_common will be accepted or not by upstream just because of this.
> 
> Note that if adding s_dev to ns_common, you then need to ensure s_dev
> contains valid value for all usages of ns_common, practically all
> namespaces, not just nsfs, otherwise people may argument against this
> as existing mechanism works and the change brings little value.
> If you go this route, please ensure other namespaces can also
> take advantage of this field.

This route seems like a long one, but is the easier solution that I can 
think at this moment.I'll read more of the code to have a better 
understanding of the consequences.


>>
>> - Add a new helper named  bpf_get_current_pid_tgid_from_ns that will 
>> return pid/tgid from the current task if pid ns matches ino and dev 
>> supplied by the user as now both values are in ns_common.
> 
> I think current helper get_ns_current_pid_tgid() can already do this.
> Did I miss anything?
> 

The problem with get_ns_current_pid_tgid is that device and ino provided 
by the user are compared against the current task pid namespace ino but 
dev_t as is not part of ns_common is compared with against the current 
nsfs dev_t. So the helper will only return pid/tgid from the current 
namespace but not will be able to do it for a target ns due to this 
limitation.


>>
>>
>>
>>
>>
>> On Fri, Nov 13, 2020 at 1:59 PM Yonghong Song <yhs@fb.com 
>> <mailto:yhs@fb.com>> wrote:
>>
>>
>>
>>     On 11/13/20 6:34 AM, carlos antonio neira bustos wrote:
>>      > Hi Blaise and Daniel,
>>      >
>>      >
>>      > I was following a couple of months ago how bpftrace was going to
>>     handle
>>      > this situation. I thought this PR
>>      > https://github.com/iovisor/bpftrace/pull/1602
>>     <https://github.com/iovisor/bpftrace/pull/1602>
>>      > <https://github.com/iovisor/bpftrace/pull/1602
>>     <https://github.com/iovisor/bpftrace/pull/1602>> was going to be 
>> merged
>>      > but just found today that is not working.
>>      >
>>      > I agree with Yonghong Song on the approach of using the two 
>> helpers
>>      > (bpf_get_pid_tgid() and bpf_get_ns_current_pid_tgid()) to move
>>     forward
>>      > on the short term, bpf_get_ns_current_pid_tgid works as a
>>     replacement
>>      > to bpf_get_pid_tgid when you are instrumenting inside a container.
>>      >
>>      > But the use case described by Blaise is one I would like to use
>>     bpftrace,
>>      >
>>      > If nobody is against it, I could start working on a new helper to
>>      > address that situation as I need to have bpftrace working in that
>>     scenario.
>>
>>     Yes, please. Thanks!
>>
>>      >
>>      > For my understanding of the problem the new helper should be 
>> able to
>>      > return pid/tgid from a target namespace, is that correct?.
>>
>>     Yes. This way, the stack trace can correlate to target namespace for
>>     symbolization purpose.
>>
>>      >
>>      >
>>      > Bests
>>      >
>>      >
>>     [...]
>>


  reply	other threads:[~2021-06-16 21:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 22:20 Extending bpf_get_ns_current_pid_tgid() Daniel Xu
2020-11-13  0:27 ` Yonghong Song
2020-11-13  0:57   ` Daniel Xu
2020-11-13  4:13     ` Yonghong Song
2020-11-13 12:04       ` Blaise Sanouillet
2020-11-13 16:57         ` Yonghong Song
     [not found]         ` <CACiB22i6d2skkJJa7uwVRrYy7dtYOxmLgFwzjtieW4BFn2tzLw@mail.gmail.com>
2020-11-13 16:59           ` Yonghong Song
     [not found]             ` <CACiB22iU3zk4Row=wAween=rSvHJ7j7M5T2KbyFk38arzEwQpQ@mail.gmail.com>
2021-06-16  9:54               ` Blaise Sanouillet
2021-06-16 17:02               ` Yonghong Song
2021-06-16 21:44                 ` Carlos Neira [this message]
2021-06-17  2:49                   ` Yonghong Song
2021-06-17 10:59                     ` Blaise Sanouillet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8b656897-8241-daed-861d-d33beff7934f@gmail.com \
    --to=cneirabustos@gmail.com \
    --cc=blez@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=dxu@dxuuu.xyz \
    --cc=ebiederm@xmission.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox