[PATCH v2] linux: open and openat ignore 'mode' with O_TMPFILE in flags
Rich Felker
dalias@libc.org
Sun Nov 2 16:44:00 GMT 2014
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
> again.
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.
Rich
More information about the Libc-alpha
mailing list