This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH v2] linux: open and openat ignore 'mode' with O_TMPFILE in flags
- From: Eric Rannaud <e at nanocritical dot com>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Cc: Roland McGrath <roland at hack dot frob dot com>,libc-alpha at sourceware dot org,joseph at codesourcery dot com
- Date: Sun, 02 Nov 2014 09:59:56 -0800
- Subject: Re: [PATCH v2] linux: open and openat ignore 'mode' with O_TMPFILE in flags
- Authentication-results: sourceware.org; auth=none
- References: <CAH_=xoZcXehKgY6jviDbmUpOxS7Vn_pWm75zzr+mT4dGop5sjQ at mail dot gmail dot com> <9e272d5ae70d7db36329c99785aefa9d32f0964d dot 1414714637 dot git dot e at nanocritical dot com> <CAH_=xoZbC1064T13ZXXdYp8c2mU15QANumefm1XzWCEG-XuDMg at mail dot gmail dot com> <87bnopwq3c dot fsf at mid dot deneb dot enyo dot de>
On Nov 2, 2014 7:59 AM, "Florian Weimer" <firstname.lastname@example.org> 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
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.