This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] linux: open and openat ignore 'mode' with O_TMPFILE in flags


On Nov 2, 2014 7:59 AM, "Florian Weimer" <fw@deneb.enyo.de> wrote:
> Anyway, I think the definition of __OPEN_NEEDS_MODE is still
> incorrect. It should check for any unknown flags in addition to
> O_CREAT and O_TMPFILE. Otherwise, we'll run into the same problem
> again.

Checking for any unknown bit, not having any idea whether it means 'mode' is actually needed, seems like a weird middle ground between the current code and unconditionally reading the mode argument.

That is, if unknown bits are found, read mode without proper cause and invoke undefined behavior.

Could we have the kernel define __OPEN_NEEDS_MODE() for us? Do we have examples of the kernel headers defining that kind of macro? We could either use it directly, or check that the glibc definition is up-to-date in a test.

The kernel actually had a very similar bug in the early history of O_TMPFILE: some code was only checking for O_CREAT. So maybe such a macro would be useful for them too, and they could fairly easily make sure they keep that macro up to date as well.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]