From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DCBBC282CE for ; Tue, 4 Jun 2019 15:12:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 093BA2053B for ; Tue, 4 Jun 2019 15:12:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727862AbfFDPMq (ORCPT ); Tue, 4 Jun 2019 11:12:46 -0400 Received: from guitar.tcltek.co.il ([192.115.133.116]:60577 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727790AbfFDPMq (ORCPT ); Tue, 4 Jun 2019 11:12:46 -0400 Received: from tarshish (unknown [10.0.8.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.tkos.co.il (Postfix) with ESMTPS id B0B5644059C; Tue, 4 Jun 2019 18:12:43 +0300 (IDT) References: User-agent: mu4e 1.0; emacs 26.1 From: Baruch Siach To: Geert Uytterhoeven Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , netdev , bpf@vger.kernel.org, "Dmitry V . Levin" , Jiri Olsa , Linus Torvalds Subject: Re: [PATCH] bpf: fix uapi bpf_prog_info fields alignment In-reply-to: Date: Tue, 04 Jun 2019 18:12:43 +0300 Message-ID: <87ftopo044.fsf@tarshish> MIME-Version: 1.0 Content-Type: text/plain Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Hi Geert, On Tue, Jun 04 2019, Geert Uytterhoeven wrote: > On Tue, Jun 4, 2019 at 1:40 PM Baruch Siach 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 >> Cc: Daniel Borkmann >> Cc: Geert Uytterhoeven >> Cc: Linus Torvalds >> Signed-off-by: Baruch Siach > > 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 -