bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andriin@fb.com>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>
Subject: Re: [RFC] bpf: Fix crash on mm_init trampoline attachment
Date: Wed, 5 May 2021 23:18:23 +0200	[thread overview]
Message-ID: <YJMLn/xaybHKyA+r@krava> (raw)
In-Reply-To: <CAADnVQKE-jXi22mrOvEX_PpjK5vxNrb6m6-G71iP5ih+R5svqA@mail.gmail.com>

On Tue, May 04, 2021 at 09:42:49PM -0700, Alexei Starovoitov wrote:
> On Tue, May 4, 2021 at 5:36 PM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
> >
> > On Tue, May 4, 2021 at 6:32 AM Jiri Olsa <jolsa@redhat.com> wrote:
> > >
> > > On Mon, May 03, 2021 at 03:45:28PM -0700, Andrii Nakryiko wrote:
> > > > On Fri, Apr 30, 2021 at 6:48 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > > > >
> > > > > There are 2 mm_init functions in kernel.
> > > > >
> > > > > One in kernel/fork.c:
> > > > >   static struct mm_struct *mm_init(struct mm_struct *mm,
> > > > >                                    struct task_struct *p,
> > > > >                                    struct user_namespace *user_ns)
> > > > >
> > > > > And another one in init/main.c:
> > > > >   static void __init mm_init(void)
> > > > >
> > > > > The BTF data will get the first one, which is most likely
> > > > > (in my case) mm_init from init/main.c without arguments.
> 
> did you hack pahole in some way to get to this point?
> I don't see this with pahole master.
> mm_init in BTF matches the one in init/main.c. The void one.
> Do you have two static mm_init-s in BTF somehow?

I have only one mm_init in BTF from init/main.c like you,
but the address in kallsyms is for the mm_init from kernel/fork.c

so we attach mm_init from kernel/fork.c with prototype from init/main.c

I'm seeing same problem also for 'receive_buf' function, which I did not post

> 
> In general it's possible to have different static funcs with the same
> name in kallsyms. I found 3 'seq_start' in my .config.
> So renaming static funcs is not an option.
> The simplest approach for now is to avoid emitting BTF
> if there is more than one func (that will prevent attaching because
> there won't be any BTF for that func).

sounds good.. will prepare the pahole change

> Long term I think BTF can store the .text offset and the verifier
> can avoid kallsym lookup.
> We do store insn_off in bpf_func_info for bpf progs.
> Something like this could be done for kernel and module funcs.
> But that's long term.
> 

ok, will check on this

jirka


      reply	other threads:[~2021-05-05 21:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-30 13:47 [RFC] bpf: Fix crash on mm_init trampoline attachment Jiri Olsa
2021-05-03 22:45 ` Andrii Nakryiko
2021-05-04 13:32   ` Jiri Olsa
2021-05-05  0:36     ` Andrii Nakryiko
2021-05-05  4:42       ` Alexei Starovoitov
2021-05-05 21:18         ` Jiri Olsa [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=YJMLn/xaybHKyA+r@krava \
    --to=jolsa@redhat.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.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;
as well as URLs for NNTP newsgroup(s).