This is the mail archive of the
libc-alpha@sourceware.org
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: Eric Rannaud <e at nanocritical dot com>
- Cc: Roland McGrath <roland at hack dot frob dot com>, libc-alpha at sourceware dot org, joseph at codesourcery dot com
- Date: Fri, 31 Oct 2014 10:50:28 -0400
- 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>
On Thu, Oct 30, 2014 at 08:06:26PM -0700, Eric Rannaud wrote:
> 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.
This is valid only if you treat translation units as black boxes. If
they're not (think: LTO on glibc, which perhaps isn't supported now
but could be in the future) then all sorts of things could go wrong at
the compiler level that have nothing to do with whether this would
conceptually work at the ABI level. The most likely error seems to be
a compiler warning/error meant to catch this exact problem: calling
va_arg without a matching argument.
In principle the same could also happen at the hardware/ABI level on
some new arch; I'm kinda surprised if it doesn't already happen on
IA64.
Rich