netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carlos Antonio Neira Bustos <cneirabustos@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Networking <netdev@vger.kernel.org>, Yonghong Song <yhs@fb.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	bpf <bpf@vger.kernel.org>, Andrii Nakryiko <andriin@fb.com>
Subject: Re: [PATCH v1 bpf-next] bpf: new helper bpf_get_current_pcomm
Date: Tue, 8 Sep 2020 16:27:20 -0300	[thread overview]
Message-ID: <20200908192719.GA1300@bpf-dev> (raw)
In-Reply-To: <CAEf4BzYt3Wt5ABivJKifoW3XLL-U0B_KgXim0pUtqJUapo7raw@mail.gmail.com>

On Wed, Aug 26, 2020 at 10:25:55PM -0700, Andrii Nakryiko wrote:
> On Wed, Aug 26, 2020 at 9:06 AM Carlos Neira <cneirabustos@gmail.com> wrote:
> >
> > In multi-threaded applications bpf_get_current_comm is returning per-thread
> > names, this helper will return comm from real_parent.
> > This makes a difference for some Java applications, where get_current_comm is
> > returning per-thread names, but get_current_pcomm will return "java".
> >
> 
> Why not bpf_probe_read_kernel_str(dst, 16, task->real_parent->comm)
> for fentry/fexit/tp_btf/etc BTF-aware BPF programs or
> BPF_CORE_READ_STR_INTO(dst, task, real_parent, comm) for any BPF
> program that has bpf_probe_read_kernel[_str]() (which is pretty much
> every BPF program nowadays, I think)?
> 
> Yes, CONFIG_DEBUG_INFO_BTF=y Kconfig is a requirement, but it's a good
> idea to have that if you are using BPF anyways.
> 
> > Signed-off-by: Carlos Neira <cneirabustos@gmail.com>
> > ---
> >  include/linux/bpf.h                           |  1 +
> >  include/uapi/linux/bpf.h                      | 15 ++++-
> >  kernel/bpf/core.c                             |  1 +
> >  kernel/bpf/helpers.c                          | 28 +++++++++
> >  kernel/trace/bpf_trace.c                      |  2 +
> >  tools/include/uapi/linux/bpf.h                | 15 ++++-
> >  .../selftests/bpf/prog_tests/current_pcomm.c  | 57 +++++++++++++++++++
> >  .../selftests/bpf/progs/test_current_pcomm.c  | 17 ++++++
> >  8 files changed, 134 insertions(+), 2 deletions(-)
> >  create mode 100644 tools/testing/selftests/bpf/prog_tests/current_pcomm.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/test_current_pcomm.c
> >
> 
> [...]
Thanks Andrii,
I'll use bpf_probe_read_kernel_str(dst, 16, task->real_parent->comm),
I was not aware of that.

Bests!. 


      reply	other threads:[~2020-09-08 19:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26 16:04 [PATCH v1 bpf-next] bpf: new helper bpf_get_current_pcomm Carlos Neira
2020-08-26 17:41 ` Yonghong Song
2020-08-27  5:25 ` Andrii Nakryiko
2020-09-08 19:27   ` Carlos Antonio Neira Bustos [this message]

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=20200908192719.GA1300@bpf-dev \
    --to=cneirabustos@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=netdev@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).