From: Baruch Siach <baruch@tkos.co.il>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, netdev <netdev@vger.kernel.org>,
bpf@vger.kernel.org, "Dmitry V . Levin" <ldv@altlinux.org>,
Jiri Olsa <jolsa@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] bpf: fix uapi bpf_prog_info fields alignment
Date: Tue, 04 Jun 2019 18:12:43 +0300 [thread overview]
Message-ID: <87ftopo044.fsf@tarshish> (raw)
In-Reply-To: <CAMuHMdWbcSUyYo1sJ81qojmbB_g595dVnzQycZq0Yh5BdQYCEg@mail.gmail.com>
Hi Geert,
On Tue, Jun 04 2019, Geert Uytterhoeven wrote:
> On Tue, Jun 4, 2019 at 1:40 PM Baruch Siach <baruch@tkos.co.il> wrote:
>> Merge commit 1c8c5a9d38f60 ("Merge
>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next") undid the
>> fix from commit 36f9814a494 ("bpf: fix uapi hole for 32 bit compat
>> applications") by taking the gpl_compatible 1-bit field definition from
>> commit b85fab0e67b162 ("bpf: Add gpl_compatible flag to struct
>> bpf_prog_info") as is. That breaks architectures with 16-bit alignment
>> like m68k. Widen gpl_compatible to 32-bit to restore alignment of the
>> following fields.
>>
>> Thanks to Dmitry V. Levin his analysis of this bug history.
>>
>> Cc: Jiri Olsa <jolsa@kernel.org>
>> Cc: Daniel Borkmann <daniel@iogearbox.net>
>> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
>
> Thanks for your patch!
>
>> --- a/include/uapi/linux/bpf.h
>> +++ b/include/uapi/linux/bpf.h
>> @@ -3140,7 +3140,7 @@ struct bpf_prog_info {
>> __aligned_u64 map_ids;
>> char name[BPF_OBJ_NAME_LEN];
>> __u32 ifindex;
>> - __u32 gpl_compatible:1;
>> + __u32 gpl_compatible;
>> __u64 netns_dev;
>> __u64 netns_ino;
>
> Wouldn't it be better to change the types of the fields that require
> 8-byte alignment from __u64 to __aligned_u64, like is already used
> for the map_ids fields?
>
> Without that, some day people will need to add a new flag, and will
> convert the 32-bit flag to a bitfield again to make space, reintroducing
> the issue.
This is a minimal fix that restores the original fix of commit
36f9814a494. Would __aligned_u64 cause any negative side effect on
current ABI?
baruch
>> __u32 nr_jited_ksyms;
>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
>> index 63e0cf66f01a..fe73829b5b1c 100644
>> --- a/tools/include/uapi/linux/bpf.h
>> +++ b/tools/include/uapi/linux/bpf.h
>> @@ -3140,7 +3140,7 @@ struct bpf_prog_info {
>> __aligned_u64 map_ids;
>> char name[BPF_OBJ_NAME_LEN];
>> __u32 ifindex;
>> - __u32 gpl_compatible:1;
>> + __u32 gpl_compatible;
>> __u64 netns_dev;
>> __u64 netns_ino;
>
> Same here.
>
>> __u32 nr_jited_ksyms;
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
next prev parent reply other threads:[~2019-06-04 15:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 11:39 [PATCH] bpf: fix uapi bpf_prog_info fields alignment Baruch Siach
2019-06-04 12:04 ` Geert Uytterhoeven
2019-06-04 15:12 ` Baruch Siach [this message]
2019-06-04 15:16 ` Alexei Starovoitov
2019-06-04 15:23 ` Geert Uytterhoeven
2019-06-04 15:30 ` Alexei Starovoitov
2019-06-05 4:06 ` Baruch Siach
2019-06-05 4:13 ` 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=87ftopo044.fsf@tarshish \
--to=baruch@tkos.co.il \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=geert@linux-m68k.org \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=ldv@altlinux.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=torvalds@linux-foundation.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 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.