Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sun, 14 Nov 2021 16:45:17 +0100
From: "Alejandro Colomar (man-pages)" <>
To: Geert Uytterhoeven <>
Cc: Mickaël Salaün <>,
 Al Viro <>, Andrew Morton
 <>, Aleksa Sarai <>,
 Andy Lutomirski <>, Arnd Bergmann <>,
 Casey Schaufler <>,
 Christian Brauner <>,
 Christian Heimes <>,
 Deven Bowers <>,
 Dmitry Vyukov <>, Eric Biggers <>,
 Eric Chiang <>, Florian Weimer <>,
 James Morris <>, Jan Kara <>,
 Jann Horn <>, Jonathan Corbet <>,
 Kees Cook <>,
 Lakshmi Ramasubramanian <>,
 "Madhavan T . Venkataraman" <>,
 Matthew Garrett <>, Matthew Wilcox <>,
 Miklos Szeredi <>, Mimi Zohar <>,
 Paul Moore <>,
 Philippe Trébuchet <>,
 Scott Shell <>, Shuah Khan <>,
 Steve Dower <>, Steve Grubb <>,
 Thibaut Sautereau <>,
 Vincent Strubel <>,
 Yin Fengwei <>,,
 Linux API <>,
 Linux FS Devel <>,
 linux-integrity <>,
 Linux Kernel Mailing List <>,
 linux-security-module <>,
 Mickaël Salaün <>
Subject: Re: [PATCH v16 1/3] fs: Add trusted_for(2) syscall implementation and
 related sysctl

Hi Geert,

On 11/14/21 16:32, Geert Uytterhoeven wrote:
> Hi Alejandro,
> On Sat, Nov 13, 2021 at 8:56 PM Alejandro Colomar (man-pages)
> <> wrote:
>> On 11/13/21 14:02, Mickaël Salaün wrote:
>>>> TL;DR:
>>>> ISO C specifies that for the following code:
>>>>       enum foo {BAR};
>>>>       enum foo foobar;
>>>> typeof(foo)    shall be int
>>>> typeof(foobar) is implementation-defined
>>> I tested with some version of GCC (from 4.9 to 11) and clang (10 and 11)
>>> with different optimizations and the related sizes are at least the same
>>> as for the int type.
>> GCC has -fshort-enums to make enum types be as short as possible.  I
>> expected -Os to turn this on, since it saves space, but it doesn't.
> Changing optimization level must not change the ABI, else debugging
> would become even more of a nightmare.

I agree, but if you invoke implementation-defined,
then it's not (only) the compiler's fault.

Instead of not allowing GCC to enable -fshort-enums ever,
one can write ISO C-complying code in the parts that
will be exposed as an interface,
by just using int.

That allows using -fshort-enums
for whatever reasons it might be good.

Not saying that the kernel wants to enable it,
but it costs nothing to write non-implementation-defined code
that doesn't forbid it.

It's comparable to passing a struct (not a pointer to it)
to a function.
If you change the size of the struct,
you screw the interface.
Better pass pointers, or standard types.


Alejandro Colomar
Linux man-pages comaintainer;

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.