Source: glibc
Version: 2.19-18+deb8u4
Severity: normal
Tags: patch
Hi,
while working on a backport of systemd v230 for jessie, we ran into
issues. Our test-suite was failing on i386, specifically test-tmpfiles.
It turns out, the files created wit O_TMPFILE had broken permissions and
were unreadable. After further investigation, this turned out to be a
bug in glibc[2].
I've backported the commit to 2.19 and with that patch applied, our
test-suite completed successfully on i386. The patch I've attached did
compile successfully on i386 and it fixed our issue in systemd. There
where a few conflicts when cherry-picking the patch, so please
double-check, just in case I missed something.
It would be great if you could include this patch in your next stable
upload. I noticed that there is already an accepted upload
2.19-18+deb8u5 for jessie 8.6. It would be awesome if you could make a
follow-up upload 2.19-18+deb8u6 to get that fix into 8.6 (I think there
is still some time left for that). If not, please consider including it
for 8.7.
The commit itself has been in unstable/stretch for a while, so seen some
wider testing.
Regards,
Michael
[1]
https://buildd.debian.org/status/fetch.php?pkg=systemd=i386=230-7~bpo8%2B1=1468945449
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=17523
-- System Information:
Debian Release: stretch/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable'), (200, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
>From dfff01413587d937e077d94b07b2fa0b7d6f8080 Mon Sep 17 00:00:00 2001
From: Eric Rannaud
Date: Tue, 24 Feb 2015 13:12:26 +0530
Subject: [PATCH] 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.
Conflicts:
ChangeLog
NEWS
sysdeps/unix/sysv/linux/generic/open.c
sysdeps/unix/sysv/linux/generic/open64.c
(cherry-picked from commit 65f6f938cd562a614a68e15d0581a34b177ec29d)
---
io/bits/fcntl2.h | 18 +-
io/fcntl.h| 14 --
io/open.c | 4 ++--
io/open64.c | 4 ++--
io/open64_2.c | 4 ++--
io/open_2.c | 4 ++--
io/openat.c | 4 ++--
io/openat64.c | 4 ++--
io/openat64_2.c | 4 ++--
io/openat_2.c | 4 ++--
sysdeps/mach/hurd/open.c | 4 ++--
sysdeps/mach/hurd/openat.c| 4 ++--
sysdeps/posix/open64.c| 4 ++--
sysdeps/unix/sysv/linux/dl-openat64.c | 2 +-
sysdeps/unix/sysv/linux/open64.c | 4 ++--
sysdeps/unix/sysv/linux/openat.c | 6 +++---
16 files changed, 49 insertions(+), 39 deletions(-)
diff --git a/io/bits/fcntl2.h b/io/bits/fcntl2.h
index 4f13b10..bb8d233 100644
--- a/io/bits/fcntl2.h
+++ b/io/bits/fcntl2.h
@@ -20,7 +20,7 @@
# error "Never include directly; use instead."
#endif
-/* Check that calls to open and openat with O_CREAT set have an
+/* Check that calls to open and openat with O_CREAT or O_TMPFILE set have an
appropriate