lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1467131978-669-23-git-send-email-ynorov@caviumnetworks.com>
Date:	Tue, 28 Jun 2016 19:39:37 +0300
From:	Yury Norov <ynorov@...iumnetworks.com>
To:	<libc-alpha@...rceware.org>, <linux-kernel@...r.kernel.org>
CC:	<arnd@...db.de>, <catalin.marinas@....com>,
	<marcus.shawcroft@....com>, <philb@....org>, <davem@...emloft.net>,
	<szabolcs.nagy@....com>, <maxim.kuvyrkov@...aro.org>,
	<joseph@...esourcery.com>, <pinskia@...il.com>,
	<bamvor.zhangjian@...wei.com>, <schwab@...e.de>,
	<fweimer@...hat.com>, <Prasun.Kapoor@...ium.com>,
	<cmetcalf@...lanox.com>, <hjl.tools@...il.com>,
	<adhemerval.zanella@...aro.org>,
	Yury Norov <ynorov@...iumnetworks.com>
Subject: [PATCH 22/23] off_t: fix register pair calculation for 64-bit case

There are 3 syscall wrappers under sysdeps/unix/sysv/linux that
calculate register pair for off_t like this:
        __LONG_LONG_PAIR (offset >> 31, offset)

While it works for 32-bit off_t, new 32-bit APIs that use 64-bit
off_t will be broken with it. This patch redirects affected syscalls
to their 64-bit versions. It also saves few instructions and symbols
in glibc, as 32-bit syscall wrappers are not generated anymore.

This patch has also been sent separately and is found correct during
discussion.

Signed-off-by: Yury Norov <ynorov@...iumnetworks.com>
---
 sysdeps/unix/sysv/linux/fallocate.c         | 4 ++++
 sysdeps/unix/sysv/linux/fallocate64.c       | 4 ++++
 sysdeps/unix/sysv/linux/posix_fadvise.c     | 4 ++++
 sysdeps/unix/sysv/linux/posix_fadvise64.c   | 4 ++++
 sysdeps/unix/sysv/linux/posix_fallocate.c   | 4 ++++
 sysdeps/unix/sysv/linux/posix_fallocate64.c | 4 ++++
 6 files changed, 24 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/fallocate.c b/sysdeps/unix/sysv/linux/fallocate.c
index 6a58a5f..4ec55a5 100644
--- a/sysdeps/unix/sysv/linux/fallocate.c
+++ b/sysdeps/unix/sysv/linux/fallocate.c
@@ -20,6 +20,8 @@
 #include <sysdep-cancel.h>
 
 
+#ifndef	__OFF_T_MATCHES_OFF64_T
+
 /* Reserve storage for the data of the file associated with FD.  */
 int
 fallocate (int fd, int mode, __off_t offset, __off_t len)
@@ -33,3 +35,5 @@ fallocate (int fd, int mode, __off_t offset, __off_t len)
   return -1;
 #endif
 }
+
+#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/fallocate64.c b/sysdeps/unix/sysv/linux/fallocate64.c
index 8e76d6f..f4f73d5 100644
--- a/sysdeps/unix/sysv/linux/fallocate64.c
+++ b/sysdeps/unix/sysv/linux/fallocate64.c
@@ -35,3 +35,7 @@ fallocate64 (int fd, int mode, __off64_t offset, __off64_t len)
   return -1;
 #endif
 }
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+weak_alias(fallocate64, fallocate)
+#endif
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c
index 093d707..8356bc7 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise.c
@@ -19,6 +19,8 @@
 #include <fcntl.h>
 #include <sysdep.h>
 
+#ifndef	__OFF_T_MATCHES_OFF64_T
+
 /* Advice the system about the expected behaviour of the application with
    respect to the file associated with FD.  */
 
@@ -46,3 +48,5 @@ posix_fadvise (int fd, off_t offset, off_t len, int advise)
   return ENOSYS;
 #endif
 }
+
+#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c
index 6d10558..c76d52f 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c
@@ -56,3 +56,7 @@ compat_symbol (libc, __posix_fadvise64_l32, posix_fadvise64, GLIBC_2_2);
 #else
 strong_alias (__posix_fadvise64_l64, posix_fadvise64);
 #endif
+
+#ifdef	__OFF_T_MATCHES_OFF64_T
+weak_alias(__posix_fadvise64_l64, __posix_fadvise)
+#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c
index fc9ac37..f9ca34b 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate.c
@@ -18,6 +18,8 @@
 #include <fcntl.h>
 #include <sysdep.h>
 
+#ifndef	__OFF_T_MATCHES_OFF64_T
+
 #define posix_fallocate static internal_fallocate
 #include <sysdeps/posix/posix_fallocate.c>
 #undef posix_fallocate
@@ -37,3 +39,5 @@ posix_fallocate (int fd, __off_t offset, __off_t len)
     return INTERNAL_SYSCALL_ERRNO (res, err);
   return internal_fallocate (fd, offset, len);
 }
+
+#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c
index 4a0a722..3a65d35 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate64.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c
@@ -40,3 +40,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
     return INTERNAL_SYSCALL_ERRNO (res, err);
   return internal_fallocate64 (fd, offset, len);
 }
+
+#ifdef	__OFF_T_MATCHES_OFF64_T
+weak_alias(__posix_fallocate64_l64, posix_fallocate)
+#endif
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ