glibc/sysdeps/unix/sysv/linux/x86_64
Adhemerval Zanella 06ab719d30 Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)
This patch fixes the OFD ("file private") locks for architectures that
support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). The
issue in this case is both F_OFD_{GETLK,SETLK,SETLKW} and
F_{SET,GET}L{W}K64 expects a flock64 argument and when using old
F_OFD_* flags with a non LFS flock argument the kernel might interpret
the underlying data wrongly.  Kernel idea originally was to avoid using
such flags in non-LFS syscall, but since GLIBC uses fcntl with LFS
semantic as default it is possible to provide the functionality and
avoid the bogus struct kernel passing by adjusting the struct manually
for the required flags.

The idea follows other LFS interfaces that provide two symbols:

  1. A new LFS fcntl64 is added on default ABI with the usual macros to
     select it for FILE_OFFSET_BITS=64.

  2. The Linux non-LFS fcntl use a stack allocated struct flock64 for
     F_OFD_{GETLK,SETLK,SETLKW} copy the results on the user provided
     struct.

  3. Keep a compat symbol with old broken semantic for architectures
     that do not define __OFF_T_MATCHES_OFF64_T.

So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will
aliased to fcntl and no adjustment would be required.  So to actually
use F_OFD_* with LFS support the source must be built with LFS support
(_FILE_OFFSET_BITS=64).

Also F_OFD_SETLKW command is handled a cancellation point, as for
F_SETLKW{64}.

Checked on x86_64-linux-gnu and i686-linux-gnu.

	[BZ #20251]
	* NEWS: Mention fcntl64 addition.
	* csu/check_fds.c: Replace __fcntl_nocancel by __fcntl64_nocancel.
	* login/utmp_file.c: Likewise.
	* sysdeps/posix/fdopendir.c: Likewise.
	* sysdeps/posix/opendir.c: Likewise.
	* sysdeps/unix/pt-fcntl.c: Likewise.
	* include/fcntl.h (__libc_fcntl64, __fcntl64,
	__fcntl64_nocancel_adjusted): New prototype.
	(__fcntl_nocancel_adjusted): Remove prototype.
	* io/Makefile (routines): Add fcntl64.
	(CFLAGS-fcntl64.c): New rule.
	* io/Versions [GLIBC_2.28] (fcntl64): New symbol.
	[GLIBC_PRIVATE] (__libc_fcntl): Rename to __libc_fcntl64.
	* io/fcntl.h (fcntl64): Add prototype and redirect if
	__USE_FILE_OFFSET64 is defined.
	* io/fcntl64.c: New file.
	* manual/llio.text: Add a note for which commands fcntl acts a
	cancellation point.
	* nptl/Makefile (CFLAGS-fcntl64.c): New rule.
	* sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols.
	* sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl, fcntl64):
	New symbols.
	* sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64,
	F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for
	non-LFS case.
	* sysdeps/unix/sysv/linux/fcntl64.c: New file.
	* sysdeps/unix/sysv/linux/fcntl_nocancel.c (__fcntl_nocancel): Rename
	to __fcntl64_nocancel.
	(__fcntl_nocancel_adjusted): Rename to __fcntl64_nocancel_adjusted.
	* sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): Rename
	to __fcntl64_nocancel.
	* sysdeps/unix/sysv/linux/tst-ofdlocks.c: New file.
	* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise.
	* sysdeps/unix/sysv/linux/Makefile (tests): Add tst-ofdlocks.
	(tests-internal): Add tst-ofdlocks-compat.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28]
	(fcntl64): New symbol.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist [GLIBC_2.28] (fcntl,
	fcntl64): Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
2018-06-26 13:22:53 -03:00
..
64 Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251) 2018-06-26 13:22:53 -03:00
x32 Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251) 2018-06-26 13:22:53 -03:00
____longjmp_chk.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
__start_context.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
brk.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
cancellation.S nptl: Remove __ASSUME_PRIVATE_FUTEX 2018-05-17 04:25:10 -07:00
clone.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
compat-timer.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
configure Move architecture cases out of sysdeps/unix/sysv/linux/configure.ac. 2014-06-24 20:53:03 +00:00
configure.ac Move architecture cases out of sysdeps/unix/sysv/linux/configure.ac. 2014-06-24 20:53:03 +00:00
dl-cache.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-procinfo.c Add _dl_x86_cpu_features to rtld_global 2015-08-13 03:41:22 -07:00
dl-procinfo.h x86: Set dl_platform and dl_hwcap from CPU features [BZ #21391] 2017-05-03 13:44:35 -07:00
get_clockfreq.c Update. 2003-05-09 07:53:33 +00:00
getcontext.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
Implies NPTL is no longer an add-on! 2014-07-07 09:29:06 -07:00
init-first.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ipc_priv.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
kernel_stat.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
kernel-features.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ldconfig.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ldd-rewrite.sed Add x32 support to ldd-rewrite.sed 2012-03-19 15:18:44 -07:00
libc-cancellation.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
libc-lowlevellock.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
libmvec.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
librt-cancellation.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
lll_timedlock_wait.c Split timed-wait functions out of nptl/lowlevellock.c. 2015-05-26 14:49:13 -07:00
lll_timedwait_tid.c Split timed-wait functions out of nptl/lowlevellock.c. 2015-05-26 14:49:13 -07:00
lowlevellock.h Define GEN_AS_CONST_HEADERS when generating header files [BZ #22792] 2018-02-23 11:29:39 -08:00
lowlevellock.S nptl: Remove __ASSUME_PRIVATE_FUTEX 2018-05-17 04:25:10 -07:00
makecontext.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
Makefile Add x86 32 bit vDSO time function support 2015-01-12 16:03:58 -02:00
profil-counter.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
pthread_setaffinity.c Move remaining nptl/sysdeps/unix/sysv/linux/x86_64/ files. 2014-05-14 12:33:43 -07:00
readelflib.c Add x32 support to ldconfig 2012-03-16 15:20:45 -07:00
register-dump.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sched_setaffinity.c * sysdeps/unix/sysv/linux/sched_setaffinity.c 2007-05-10 23:38:55 +00:00
setcontext.S x86-64/setcontext: Pop the pointer into %rdx after syscall 2018-05-02 06:21:24 -07:00
sigaction.c linux: Consolidate sigaction implementation 2018-04-05 17:09:50 -03:00
sigaltstack-offsets.sym Use R*_LP, sizeSS, oSS_FLAGS, oSS_SP and oSS_SIZE 2012-05-15 16:43:11 -07:00
sigcontextinfo.h Remove unused frame.h header, sigcontextinfo.h macros. 2018-03-22 16:40:51 +00:00
sigprocmask.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
swapcontext.S x86-64/swapcontext: Restore the pointer into %rdx after syscall 2018-05-02 06:26:19 -07:00
syscall.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
syscalls.list Remove p{read,write}{v} and fallocate from x86 auto-generation list 2017-08-22 17:27:18 -03:00
sysdep.h x86_64: Fix build with RTLD_PRIVATE_ERRNO defined to 1 2018-03-18 02:11:56 +01:00
sysdep.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
timer_create.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
timer_delete.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
timer_getoverr.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
timer_gettime.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
timer_settime.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ucontext_i.sym . 2007-07-31 13:33:18 +00:00
Versions Revert {send,sendm,recv,recvm}msg conformance changes 2016-06-10 11:58:16 -03:00
vfork.S Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00