glibc/sysdeps
Eric Rannaud 65f6f938cd linux: open and openat ignore 'mode' with O_TMPFILE in flags
Both open and openat load their last argument 'mode' lazily, using
va_arg() only if O_CREAT is found in oflag. This is wrong, mode is also
necessary if O_TMPFILE is in oflag.

By chance on x86_64, the problem wasn't evident when using O_TMPFILE
with open, as the 3rd argument of open, even when not loaded with
va_arg, is left untouched in RDX, where the syscall expects it.

However, openat was not so lucky, and O_TMPFILE couldn't be used: mode
is the 4th argument, in RCX, but the syscall expects its 4th argument in
a different register than the glibc wrapper, in R10.

Introduce a macro __OPEN_NEEDS_MODE (oflag) to test if either O_CREAT or
O_TMPFILE is set in oflag.

Tested on Linux x86_64.

	[BZ #17523]
	* io/fcntl.h (__OPEN_NEEDS_MODE): New macro.
	* io/bits/fcntl2.h (open): Use it.
	(openat): Likewise.
	* io/open.c (__libc_open): Likewise.
	* io/open64.c (__libc_open64): Likewise.
	* io/open64_2.c (__open64_2): Likewise.
	* io/open_2.c (__open_2): Likewise.
	* io/openat.c (__openat): Likewise.
	* io/openat64.c (__openat64): Likewise.
	* io/openat64_2.c (__openat64_2): Likewise.
	* io/openat_2.c (__openat_2): Likewise.
	* sysdeps/mach/hurd/open.c (__libc_open): Likewise.
	* sysdeps/mach/hurd/openat.c (__openat): Likewise.
	* sysdeps/posix/open64.c (__libc_open64): Likewise.
	* sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
	* sysdeps/unix/sysv/linux/generic/open.c (__libc_open): Likewise.
	(__open_nocancel): Likewise.
	* sysdeps/unix/sysv/linux/generic/open64.c (__libc_open64): Likewise.
	* sysdeps/unix/sysv/linux/open64.c (__libc_open64): Likewise.
	* sysdeps/unix/sysv/linux/openat.c (__OPENAT): Likewise.
2015-02-24 13:19:22 +05:30
..
aarch64 Clean up sysdep-dl-routines variable. 2015-02-06 10:42:08 -08:00
alpha Fix libm feupdateenv namespace (bug 17748). 2015-01-07 19:01:20 +00:00
arm Use -Werror=undef for assembly code. 2015-02-12 13:57:32 -08:00
generic Add placeholder c++-types.data and *.abilist files. 2015-02-13 15:41:34 -08:00
gnu hurd: fix unwind-resume.c build 2015-02-08 18:46:00 +01:00
hppa Clean up sysdep-dl-routines variable. 2015-02-06 10:42:08 -08:00
i386 Fix atan / atan2 missing underflows (bug 15319). 2015-02-18 21:10:49 +00:00
ia64 Clean up sysdep-dl-routines variable. 2015-02-06 10:42:08 -08:00
ieee754 Fix atan / atan2 missing underflows (bug 15319). 2015-02-18 21:10:49 +00:00
init_array NPTL: Initializer for .init_array-only configurations. 2015-02-13 13:19:11 -08:00
m68k m68k: fix missing definition of __feraiseexcept 2015-01-25 23:36:02 +01:00
mach linux: open and openat ignore 'mode' with O_TMPFILE in flags 2015-02-24 13:19:22 +05:30
microblaze MicroBlaze: Avoid pointer to integer conversion warning 2015-01-09 14:49:27 +10:00
mips 2015-02-18 Steve Ellcey <sellcey@imgtec.com> 2015-02-18 10:51:37 -08:00
nios2 glibc 2.21 pre-release update. 2015-02-05 23:14:38 -05:00
nptl Include <signal.h> in sysdeps/nptl/allocrtsig.c 2015-01-29 10:00:25 +01:00
posix linux: open and openat ignore 'mode' with O_TMPFILE in flags 2015-02-24 13:19:22 +05:30
powerpc Fix powerpc software sqrtf (bug 17967). 2015-02-13 16:20:36 +00:00
pthread hurd: fix build with pthread aio 2015-02-07 21:48:32 +01:00
s390 s390: Use generic lowlevellock-futex.h 2015-02-20 10:48:06 +01:00
sh Fix libm feupdateenv namespace (bug 17748). 2015-01-07 19:01:20 +00:00
sparc Fix two bugs in sparc atomics. 2015-01-31 23:39:50 -08:00
tile tilegx32: set __HAVE_64B_ATOMICS to 0 2015-01-28 14:51:21 -05:00
unix linux: open and openat ignore 'mode' with O_TMPFILE in flags 2015-02-24 13:19:22 +05:30
wordsize-32 Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
wordsize-64 Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
x86 Fix atan / atan2 missing underflows (bug 15319). 2015-02-18 21:10:49 +00:00
x86_64 Fix atan / atan2 missing underflows (bug 15319). 2015-02-18 21:10:49 +00:00