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: Rich Felker <dalias at libc dot org>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Cc: Eric Rannaud <e at nanocritical dot com>, Roland McGrath <roland at hack dot frob dot com>, libc-alpha at sourceware dot org, joseph at codesourcery dot com
- Date: Sun, 2 Nov 2014 11:44:15 -0500
- 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 Sun, Nov 02, 2014 at 04:59:35PM +0100, Florian Weimer wrote:
> * Eric Rannaud:
> > This patch above is a straightforward fix, but Linus asks: why not
> > invoke va_arg() unconditionally? The 'mode' argument thus read could
> > not be used by the wrapper, as it could contain garbage, but it could
> > be passed untouched to the kernel.
> If technically undefined behavior which just happens to work is
> acceptable, you could also add the optional argument to the argument
> list. This would address the performance concern which may have been
> the reason to make the va_arg call conditional.
I don't think it's acceptable.
> 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
It's unlikely that such a flag will ever be added again, and it really
should not have happened with O_TMPFILE. O_TMPFILE is fundamentally a
"create" operation and should have either requried O_CREAT with it, or
had O_CREAT built into the bits of its definition. This was an
oversight on the part of the kernel folks when they added it.