Go to file
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
argp
assert Add ersatz _Static_assert on older C hosts 2015-02-07 14:43:27 -08:00
benchtests
bits
catgets
conf
conform Fix scandir scandirat namespace (bug 17999). 2015-02-19 17:18:51 +00:00
crypt
csu Compile gcrt1.o with -fPIC 2015-02-23 06:28:33 -08:00
ctype
debug Conditionalize some tests' use of SA_SIGINFO. 2015-02-06 12:29:50 -08:00
dirent Fix scandir scandirat namespace (bug 17999). 2015-02-19 17:18:51 +00:00
dlfcn
elf Fix failure of elf/tst-audit2 when compiled with GCC-5 2015-02-23 12:35:54 +01:00
gmon
gnulib
grp
gshadow
hesiod
hurd add hurd/hurdsocket.h file missing from a5eb23d 2015-02-08 17:49:16 +01:00
iconv
iconvdata
include Amendments to Unicode 7 update. 2015-02-23 11:35:24 -03:00
inet
intl
io linux: open and openat ignore 'mode' with O_TMPFILE in flags 2015-02-24 13:19:22 +05:30
libidn
libio Fix BZ #17269 -- _IO_wstr_overflow integer overflow 2015-02-22 12:01:47 -08:00
locale
localedata Amendments to Unicode 7 update. 2015-02-23 11:35:24 -03:00
login
mach
malloc Consolidate arena_lookup and arena_lock into a single arena_get 2015-02-18 11:06:06 +05:30
manual Refine documentation of libm exceptions goals. 2015-02-17 23:41:27 +00:00
math Adjust timeouts for some tests, to accommodate slow processors, 2015-02-22 01:05:02 -08:00
misc Fix search.h namespace (bug 17996). 2015-02-18 18:47:34 +00:00
nis
nptl Make error checking effective in nptl/tst-cond25.c. 2015-02-16 18:11:14 +01:00
nptl_db
nscd
nss
po
posix
pwd
resolv Skip logging for DNSSEC responses [BZ 14841] 2015-02-24 13:17:29 +05:30
resource Fix posix_spawn getrlimit64 namespace (bug 17991). 2015-02-18 00:26:35 +00:00
rt Don't set unused field in rt/tst-timer2. 2015-02-06 12:30:38 -08:00
scripts
setjmp
shadow
signal
socket
soft-fp soft-fp: Adjust call to abort for kernel use. 2015-02-20 18:07:03 +00:00
stdio-common
stdlib
streams
string Remove unused definitions 2015-02-11 12:50:53 +01:00
sunrpc
sysdeps linux: open and openat ignore 'mode' with O_TMPFILE in flags 2015-02-24 13:19:22 +05:30
sysvipc
termios
time Fix time/getdate.c build. 2015-02-08 17:45:25 +01:00
timezone
wcsmbs Remove unused definitions 2015-02-11 12:50:53 +01:00
wctype
.gitattributes
.gitignore
abi-tags Revert "hurd: Fix abi-tag, following ba90e05" 2015-02-11 23:51:51 +00:00
aclocal.m4
BUGS
ChangeLog linux: open and openat ignore 'mode' with O_TMPFILE in flags 2015-02-24 13:19:22 +05:30
ChangeLog.1
ChangeLog.2
ChangeLog.3
ChangeLog.4
ChangeLog.5
ChangeLog.6
ChangeLog.7
ChangeLog.8
ChangeLog.9
ChangeLog.10
ChangeLog.11
ChangeLog.12
ChangeLog.13
ChangeLog.14
ChangeLog.15
ChangeLog.16
ChangeLog.17
ChangeLog.old-ports
ChangeLog.old-ports-aarch64
ChangeLog.old-ports-aix
ChangeLog.old-ports-alpha
ChangeLog.old-ports-am33
ChangeLog.old-ports-arm
ChangeLog.old-ports-cris
ChangeLog.old-ports-hppa
ChangeLog.old-ports-ia64
ChangeLog.old-ports-linux-generic
ChangeLog.old-ports-m68k
ChangeLog.old-ports-microblaze
ChangeLog.old-ports-mips
ChangeLog.old-ports-powerpc
ChangeLog.old-ports-tile
config.h.in
config.make.in
configure Revert "hurd: Fix abi-tag, following ba90e05" 2015-02-11 23:51:51 +00:00
configure.ac Revert "hurd: Fix abi-tag, following ba90e05" 2015-02-11 23:51:51 +00:00
CONFORMANCE
COPYING
COPYING.LIB
cppflags-iterator.mk
extra-lib.mk
extra-modules.mk
INSTALL
libc-abis
LICENSES
Makeconfig Use -Werror=undef for assembly code. 2015-02-12 13:57:32 -08:00
Makefile
Makefile.in
Makerules Support after-link variable to run a final step on binaries. 2015-02-12 13:38:47 -08:00
NAMESPACE
NEWS linux: open and openat ignore 'mode' with O_TMPFILE in flags 2015-02-24 13:19:22 +05:30
o-iterator.mk
PROJECTS
README Another pointless update in README. 2015-02-11 14:39:30 -08:00
Rules
shlib-versions
test-skeleton.c
version.h
WUR-REPORT

This directory contains the sources of the GNU C Library.
See the file "version.h" for what release version you have.

The GNU C Library is the standard system C library for all GNU systems,
and is an important part of what makes up a GNU system.  It provides the
system API for all programs written in C and C-compatible languages such
as C++ and Objective C; the runtime facilities of other programming
languages use the C library to access the underlying operating system.

In GNU/Linux systems, the C library works with the Linux kernel to
implement the operating system behavior seen by user applications.
In GNU/Hurd systems, it works with a microkernel and Hurd servers.

The GNU C Library implements much of the POSIX.1 functionality in the
GNU/Hurd system, using configurations i[4567]86-*-gnu.  The current
GNU/Hurd support requires out-of-tree patches that will eventually be
incorporated into an official GNU C Library release.

When working with Linux kernels, this version of the GNU C Library
requires Linux kernel version 2.6.32 or later.

Also note that the shared version of the libgcc_s library must be
installed for the pthread library to work correctly.

The GNU C Library supports these configurations for using Linux kernels:

	aarch64*-*-linux-gnu
	alpha*-*-linux-gnu
	arm-*-linux-gnueabi
	hppa-*-linux-gnu	Not currently functional without patches.
	i[4567]86-*-linux-gnu
	x86_64-*-linux-gnu	Can build either x86_64 or x32
	ia64-*-linux-gnu
	m68k-*-linux-gnu
	microblaze*-*-linux-gnu
	mips-*-linux-gnu
	mips64-*-linux-gnu
	powerpc-*-linux-gnu	Hardware or software floating point, BE only.
	powerpc64*-*-linux-gnu	Big-endian and little-endian.
	s390-*-linux-gnu
	s390x-*-linux-gnu
	sh[34]-*-linux-gnu
	sparc*-*-linux-gnu
	sparc64*-*-linux-gnu
	tilegx-*-linux-gnu
	tilepro-*-linux-gnu

If you are interested in doing a port, please contact the glibc
maintainers; see http://www.gnu.org/software/libc/ for more
information.

See the file INSTALL to find out how to configure, build, and install
the GNU C Library.  You might also consider reading the WWW pages for
the C library at http://www.gnu.org/software/libc/.

The GNU C Library is (almost) completely documented by the Texinfo manual
found in the `manual/' subdirectory.  The manual is still being updated
and contains some known errors and omissions; we regret that we do not
have the resources to work on the manual as much as we would like.  For
corrections to the manual, please file a bug in the `manual' component,
following the bug-reporting instructions below.  Please be sure to check
the manual in the current development sources to see if your problem has
already been corrected.

Please see http://www.gnu.org/software/libc/bugs.html for bug reporting
information.  We are now using the Bugzilla system to track all bug reports.
This web page gives detailed information on how to report bugs properly.

The GNU C Library is free software.  See the file COPYING.LIB for copying
conditions, and LICENSES for notices about a few contributions that require
these additional notices to be distributed.  License copyright years may be
listed using range notation, e.g., 1996-2015, indicating that every year in
the range, inclusive, is a copyrightable year that would otherwise be listed
individually.