From: Delyan Kratunov <delyank@fb.com>
To: "daniel@iogearbox.net" <daniel@iogearbox.net>,
"ast@kernel.org" <ast@kernel.org>,
"andrii@kernel.org" <andrii@kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: [PATCH bpf-next v1 0/3] Avoid typedef size mismatches in skeletons
Date: Thu, 10 Feb 2022 00:36:56 +0000 [thread overview]
Message-ID: <cover.1644453291.git.delyank@fb.com> (raw)
As reported in [0], kernel and userspace can sometimes disagree
on the definition of a typedef (in particular, the size).
This leads to trouble when userspace maps the memory of a bpf program
and reads/writes to it assuming a different memory layout.
This series resolves most int-like typedefs and rewrites them as
standard int16_t-like types. In particular, we don't touch
__u32-like types, char, and _Bool, as changing them changes cast
semantics and would break too many pre-existing programs. For example,
int8_t* is not convertible to char* because int8_t is explicitly signed.
[0]: https://github.com/iovisor/bcc/pull/3777
Delyan Kratunov (3):
libbpf: btf_dump can produce explicitly sized ints
bpftool: skeleton uses explicitly sized ints
selftests/bpf: add test case for userspace and bpf type size mismatch
tools/bpf/bpftool/gen.c | 3 +
tools/lib/bpf/btf.h | 4 +-
tools/lib/bpf/btf_dump.c | 80 ++++++++++++++++++-
.../selftests/bpf/prog_tests/skeleton.c | 22 +++--
.../selftests/bpf/progs/test_skeleton.c | 8 ++
5 files changed, 107 insertions(+), 10 deletions(-)
--
2.34.1
next reply other threads:[~2022-02-10 1:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 0:36 Delyan Kratunov [this message]
2022-02-10 0:36 ` [PATCH bpf-next v1 3/3] selftests/bpf: add test case for userspace and bpf type size mismatch Delyan Kratunov
2022-02-10 22:44 ` Andrii Nakryiko
2022-02-10 23:48 ` Delyan Kratunov
2022-02-10 0:36 ` [PATCH bpf-next v1 2/3] bpftool: skeleton uses explicitly sized ints Delyan Kratunov
2022-02-10 22:42 ` Andrii Nakryiko
2022-02-10 23:45 ` Delyan Kratunov
2022-02-10 0:36 ` [PATCH bpf-next v1 1/3] libbpf: btf_dump can produce " Delyan Kratunov
2022-02-10 22:35 ` Andrii Nakryiko
2022-02-10 23:40 ` Delyan Kratunov
2022-02-10 22:18 ` [PATCH bpf-next v1 0/3] Avoid typedef size mismatches in skeletons Yonghong Song
2022-02-10 22:48 ` Andrii Nakryiko
2022-02-10 22:51 ` Yonghong Song
2022-02-10 23:14 ` Alexei Starovoitov
2022-02-10 23:59 ` Delyan Kratunov
2022-02-11 0:17 ` Alexei Starovoitov
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=cover.1644453291.git.delyank@fb.com \
--to=delyank@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.