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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 B46BDC2D0CE for ; Sun, 15 Dec 2019 20:55:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9727E2467F for ; Sun, 15 Dec 2019 20:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbfLOUz5 (ORCPT ); Sun, 15 Dec 2019 15:55:57 -0500 Received: from mout-p-201.mailbox.org ([80.241.56.171]:53040 "EHLO mout-p-201.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbfLOUz5 (ORCPT ); Sun, 15 Dec 2019 15:55:57 -0500 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 47bcBM0DybzQlB1; Sun, 15 Dec 2019 21:55:55 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id 4aLf2vSWysit; Sun, 15 Dec 2019 21:55:50 +0100 (CET) Date: Mon, 16 Dec 2019 07:55:39 +1100 From: Aleksa Sarai To: Florian Weimer Cc: Alexander Viro , Jeff Layton , "J. Bruce Fields" , Shuah Khan , dev@opencontainers.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH] openat2: switch to __attribute__((packed)) for open_how Message-ID: <20191215205539.ly2ns5wglautu47u@yavin.dot.cyphar.com> References: <20191213222351.14071-1-cyphar@cyphar.com> <87o8w9bcaf.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lhbbxkijknkbhl5m" Content-Disposition: inline In-Reply-To: <87o8w9bcaf.fsf@mid.deneb.enyo.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --lhbbxkijknkbhl5m Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2019-12-15, Florian Weimer wrote: > * Aleksa Sarai: >=20 > > diff --git a/tools/testing/selftests/openat2/helpers.h b/tools/testing/= selftests/openat2/helpers.h > > index 43ca5ceab6e3..eb1535c8fa2e 100644 > > --- a/tools/testing/selftests/openat2/helpers.h > > +++ b/tools/testing/selftests/openat2/helpers.h > > @@ -32,17 +32,16 @@ > > * O_TMPFILE} are set. > > * > > * @flags: O_* flags. > > - * @mode: O_CREAT/O_TMPFILE file mode. > > * @resolve: RESOLVE_* flags. > > + * @mode: O_CREAT/O_TMPFILE file mode. > > */ > > struct open_how { > > - __aligned_u64 flags; > > + __u64 flags; > > + __u64 resolve; > > __u16 mode; > > - __u16 __padding[3]; /* must be zeroed */ > > - __aligned_u64 resolve; > > -}; > > +} __attribute__((packed)); > > =20 > > -#define OPEN_HOW_SIZE_VER0 24 /* sizeof first published struct */ > > +#define OPEN_HOW_SIZE_VER0 18 /* sizeof first published struct */ > > #define OPEN_HOW_SIZE_LATEST OPEN_HOW_SIZE_VER0 >=20 > A userspace ABI that depends on GCC extensions probably isn't a good > idea. Even with GCC, it will not work well with some future > extensions because it pretty much rules out having arrays or other > members that are access through pointers. Current GCC does not carry > over the packed-ness of the struct to addresses of its members. Right, those are also good points. Okay, I'm going to send a separate patch which changes the return value for invalid __padding to -E2BIG, and moves the padding to the end of the struct (along with open_how.mode). That should fix all of the warts I raised, without running into the numerous problems with __attribute__((packed)) of which I am now aware. --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --lhbbxkijknkbhl5m Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQSxZm6dtfE8gxLLfYqdlLljIbnQEgUCXfadxgAKCRCdlLljIbnQ EnZkAQDEI0SqPaVjZ0DfeCNK/Oej24PSHHnlQslkzD1ijil74QD/aTyeW+1lV5OQ nKYasufz04VrST6LL+l0ZOId14X/AAE= =y9fv -----END PGP SIGNATURE----- --lhbbxkijknkbhl5m--