[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1e8f3fb4-a014-8146-70ba-65e451a64e18@fb.com>
Date: Mon, 19 Sep 2022 22:30:16 -0700
From: Yonghong Song <yhs@...com>
To: Roberto Sassu <roberto.sassu@...weicloud.com>
Cc: andrii@...nel.org, ast@...nel.org, bpf@...r.kernel.org,
daniel@...earbox.net, deso@...teo.net, dhowells@...hat.com,
haoluo@...gle.com, jarkko@...nel.org, jmorris@...ei.org,
joannelkoong@...il.com, john.fastabend@...il.com, jolsa@...nel.org,
keyrings@...r.kernel.org, kpsingh@...nel.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-security-module@...r.kernel.org, martin.lau@...ux.dev,
memxor@...il.com, mingo@...hat.com, mykolal@...com,
paul@...l-moore.com, roberto.sassu@...wei.com, rostedt@...dmis.org,
sdf@...gle.com, serge@...lyn.com, shuah@...nel.org, song@...nel.org
Subject: Re: [PATCH v18 02/13] btf: Export bpf_dynptr definition
On 9/19/22 7:27 AM, Roberto Sassu wrote:
> From: Roberto Sassu <roberto.sassu@...wei.com>
>
> eBPF dynamic pointers is a new feature recently added to upstream. It binds
> together a pointer to a memory area and its size. The internal kernel
> structure bpf_dynptr_kern is not accessible by eBPF programs in user space.
> They instead see bpf_dynptr, which is then translated to the internal
> kernel structure by the eBPF verifier.
>
> The problem is that it is not possible to include at the same time the uapi
> include linux/bpf.h and the vmlinux BTF vmlinux.h, as they both contain the
> definition of some structures/enums. The compiler complains saying that the
> structures/enums are redefined.
>
> As bpf_dynptr is defined in the uapi include linux/bpf.h, this makes it
> impossible to include vmlinux.h. However, in some cases, e.g. when using
> kfuncs, vmlinux.h has to be included. The only option until now was to
> include vmlinux.h and add the definition of bpf_dynptr directly in the eBPF
> program source code from linux/bpf.h.
>
> Solve the problem by using the same approach as for bpf_timer (which also
> follows the same scheme with the _kern suffix for the internal kernel
> structure).
>
> Add the following line in one of the dynamic pointer helpers,
> bpf_dynptr_from_mem():
>
> BTF_TYPE_EMIT(struct bpf_dynptr);
>
> Cc: stable@...r.kernel.org
> Cc: Joanne Koong <joannelkoong@...il.com>
> Fixes: 97e03f521050c ("bpf: Add verifier support for dynptrs")
> Signed-off-by: Roberto Sassu <roberto.sassu@...wei.com>
Acked-by: Yonghong Song <yhs@...com>
Powered by blists - more mailing lists