From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Jiri Olsa <olsajiri@gmail.com>, Daniel Xu <dxu@dxuuu.xyz>,
shuah@kernel.org, ast@kernel.org, andrii@kernel.org,
eddyz87@gmail.com, daniel@iogearbox.net, quentin@isovalent.com,
alan.maguire@oracle.com, acme@kernel.org, mykolal@fb.com,
martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com,
haoluo@google.com, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH bpf-next v4 06/12] bpf: selftests: Fix bpf_session_cookie() kfunc prototype
Date: Tue, 18 Jun 2024 14:43:44 +0200 [thread overview]
Message-ID: <ZnGBANDTF80gNDHR@krava> (raw)
In-Reply-To: <CAEf4BzaT7XNnGFUqAr=+pi106bT0o4=TJ7JLOPNjZEBHw4+M7Q@mail.gmail.com>
On Mon, Jun 17, 2024 at 03:25:53PM -0700, Andrii Nakryiko wrote:
> On Mon, Jun 10, 2024 at 6:04 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> >
> > On Sat, Jun 08, 2024 at 03:16:02PM -0600, Daniel Xu wrote:
> > > The prototype defined in bpf_kfuncs.h was not in line with how the
> > > actual kfunc was defined. This causes compilation errors when kfunc
> > > prototypes are generated from BTF.
> > >
> > > Fix by aligning with actual kfunc definition.
> > >
> > > Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> > > ---
> > > tools/testing/selftests/bpf/bpf_kfuncs.h | 2 +-
> > > tools/testing/selftests/bpf/progs/kprobe_multi_session_cookie.c | 2 +-
> > > 2 files changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/tools/testing/selftests/bpf/bpf_kfuncs.h b/tools/testing/selftests/bpf/bpf_kfuncs.h
> > > index be91a6919315..3b6675ab4086 100644
> > > --- a/tools/testing/selftests/bpf/bpf_kfuncs.h
> > > +++ b/tools/testing/selftests/bpf/bpf_kfuncs.h
> > > @@ -77,5 +77,5 @@ extern int bpf_verify_pkcs7_signature(struct bpf_dynptr *data_ptr,
> > > struct bpf_key *trusted_keyring) __ksym;
> > >
> > > extern bool bpf_session_is_return(void) __ksym __weak;
> > > -extern long *bpf_session_cookie(void) __ksym __weak;
> > > +extern __u64 *bpf_session_cookie(void) __ksym __weak;
> >
> > the original intent was to expose long instead of __u64 :-\
> >
>
> Cookies internally are always u64 (8 byte values). Marking them
> internally in the kernel as long could lead to problems on 32-bit
> architectures, potentially (it still needs to be 64-bit value
> according to BPF contract, but we'll allocate only 4 bytes for them).
>
> It seems better and safer to be explicit with __u64/u64 for cookies everywhere.
hum, I based that on what we did for kprobe session,
but I guess it makes sense just for bpf side:
https://lore.kernel.org/bpf/CAEf4BzbyQpKvZS-mUECLRq3gyBJbsqQghOKyAbutoB76mJM8xw@mail.gmail.com/
jirka
>
> What am I missing?
>
> > could we rather change the bpf_session_cookie function to return long?
> > should be just return value type change
> >
> > thanks,
> > jirka
> >
> >
> > > #endif
> > > diff --git a/tools/testing/selftests/bpf/progs/kprobe_multi_session_cookie.c b/tools/testing/selftests/bpf/progs/kprobe_multi_session_cookie.c
> > > index d49070803e22..0835b5edf685 100644
> > > --- a/tools/testing/selftests/bpf/progs/kprobe_multi_session_cookie.c
> > > +++ b/tools/testing/selftests/bpf/progs/kprobe_multi_session_cookie.c
> > > @@ -25,7 +25,7 @@ int BPF_PROG(trigger)
> > >
> > > static int check_cookie(__u64 val, __u64 *result)
> > > {
> > > - long *cookie;
> > > + __u64 *cookie;
> > >
> > > if (bpf_get_current_pid_tgid() >> 32 != pid)
> > > return 1;
> > > --
> > > 2.44.0
> > >
next prev parent reply other threads:[~2024-06-18 12:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-08 21:15 [PATCH bpf-next v4 00/12] bpf: Support dumping kfunc prototypes from BTF Daniel Xu
2024-06-08 21:15 ` [PATCH bpf-next v4 01/12] kbuild: bpf: Tell pahole to DECL_TAG kfuncs Daniel Xu
2024-06-08 21:15 ` [PATCH bpf-next v4 02/12] bpf: selftests: Fix bpf_iter_task_vma_new() prototype Daniel Xu
2024-06-08 21:15 ` [PATCH bpf-next v4 03/12] bpf: selftests: Fix fentry test kfunc prototypes Daniel Xu
2024-06-10 13:28 ` Jiri Olsa
2024-06-11 16:58 ` Daniel Xu
2024-06-12 12:41 ` Jiri Olsa
2024-06-08 21:16 ` [PATCH bpf-next v4 04/12] bpf: selftests: Fix bpf_cpumask_first_zero() kfunc prototype Daniel Xu
2024-06-08 21:16 ` [PATCH bpf-next v4 05/12] bpf: selftests: Fix bpf_map_sum_elem_count() " Daniel Xu
2024-06-08 21:16 ` [PATCH bpf-next v4 06/12] bpf: selftests: Fix bpf_session_cookie() " Daniel Xu
2024-06-10 13:04 ` Jiri Olsa
2024-06-11 15:54 ` Daniel Xu
2024-06-11 16:03 ` Alexei Starovoitov
2024-06-17 22:25 ` Andrii Nakryiko
2024-06-18 12:43 ` Jiri Olsa [this message]
2024-06-18 16:58 ` Andrii Nakryiko
2024-06-18 19:07 ` Jiri Olsa
2024-06-18 20:29 ` Andrii Nakryiko
2024-06-08 21:16 ` [PATCH bpf-next v4 07/12] bpf: selftests: Namespace struct_opt callbacks in bpf_dctcp Daniel Xu
2024-06-08 21:16 ` [PATCH bpf-next v4 08/12] bpf: verifier: Relax caller requirements for kfunc projection type args Daniel Xu
2024-06-10 18:30 ` Alexei Starovoitov
2024-06-11 18:01 ` Daniel Xu
2024-06-08 21:16 ` [PATCH bpf-next v4 09/12] bpf: treewide: Align kfunc signatures to prog point-of-view Daniel Xu
2024-06-08 21:16 ` [PATCH bpf-next v4 10/12] bpf: selftests: nf: Opt out of using generated kfunc prototypes Daniel Xu
2024-06-08 21:16 ` [PATCH bpf-next v4 11/12] bpf: selftests: xfrm: " Daniel Xu
2024-06-08 21:16 ` [PATCH bpf-next v4 12/12] bpftool: Support dumping kfunc prototypes from BTF Daniel Xu
2024-06-08 21:23 ` [PATCH bpf-next v4 00/12] bpf: " Daniel Xu
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=ZnGBANDTF80gNDHR@krava \
--to=olsajiri@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dxu@dxuuu.xyz \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@meta.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=quentin@isovalent.com \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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