glibc/sysdeps/generic
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
..
net Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
netinet generic if_ether.h: Fix build 2018-01-19 01:51:10 +01:00
nfs Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sys Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
Makefile Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
_G_config.h Post-cleanup 2: minimize _G_config.h. 2018-02-07 10:10:32 -05:00
_itoa.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
a.out.h
abort-instr.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
aio_misc.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
allocalim.h
asm-syntax.h
atomic-machine.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
c++-types.data Add placeholder c++-types.data and *.abilist files. 2015-02-13 15:41:34 -08:00
confstr.h
device-nrs.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dirstream.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-cache.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-dtprocnum.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-dtv.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-fcntl.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-fileid.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-fptr.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-hash.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-irel.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-librecon.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-lookupcfg.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-machine.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-mman.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-osinfo.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-procinfo.c
dl-procinfo.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-procruntime.c ld.so: Add architecture specific fields 2017-11-13 08:02:52 -08:00
dl-sysdep.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dl-tls.h
dl-unistd.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dwarf2.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
elide.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
eloop-threshold.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
entry.h
errqueue.h
exit-thread.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
fd_to_filename.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
fips-private.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
fix-fp-int-compare-invalid.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
fix-fp-int-convert-overflow.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
fix-int-fp-convert-zero.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
float128-abi.h Move some float128 symbol version definitions. 2017-10-16 22:04:42 +00:00
fork.h
fpu_control.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
framestate.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
gcc-compat.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
gccframe.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
get-rounding-mode.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
gmp-mparam.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
hp-timing-common.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
hp-timing.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ifreq.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ifunc-init.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ifunc-sel.h Do not stack-protect ifunc resolvers [BZ #7065] 2016-12-26 10:08:41 +01:00
internal-signals.h Make sysdeps/generic/internal-signals.h less stubby. 2018-04-04 12:37:23 -04:00
intr-msg.h
inttypes.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ld.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
ldbl-classify-compat.h Move LDBL_CLASSIFY_COMPAT to its own header. 2018-02-01 21:01:00 +00:00
ldconfig.h Add support for the RISC-V-specific ELF flags 2018-01-25 10:06:19 -08:00
ldsodefs.h elf: Correct absolute (SHN_ABS) symbol run-time calculation [BZ #19818] 2018-04-04 23:09:37 +01:00
libBrokenLocale.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libanl.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libc-lock.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
libc-mmap.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
libc-start.h hurd: Initialize TLS and libpthread before signal thread start 2018-03-25 00:52:39 +01:00
libc-tsd.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
libc.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libcrypt.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libdl.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libm-alias-double.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
libm-alias-float.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
libm-alias-float128.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
libm-alias-ldouble.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
libm-test-ulps
libm-test-ulps-name Do not hardcode platform names in manual/libm-err-tab.pl (bug 14139). 2016-11-04 16:49:06 +00:00
libm.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libnsl.abilist Add placeholder libnsl.abilist and libutil.abilist files 2016-03-07 00:49:36 +01:00
libnss_compat.abilist
libnss_db.abilist
libnss_dns.abilist
libnss_files.abilist
libnss_hesiod.abilist
libnss_nis.abilist
libnss_nisplus.abilist
libpthread.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libresolv.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
librt.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libutil.abilist Add placeholder libnsl.abilist and libutil.abilist files 2016-03-07 00:49:36 +01:00
link_map.h ld.so: Add architecture specific fields 2017-11-13 08:02:52 -08:00
linkmap.h Rename bits/linkmap.h to linkmap.h (bug 14912). 2015-09-04 19:44:27 +00:00
local-setxid.h
localplt.data ld.so: Introduce struct dl_exception 2017-08-10 16:54:57 +02:00
machine-gmon.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
machine-lock.h hurd: take __USE_EXTERN_INLINES into account and restrict inlines 2018-01-28 18:46:23 +01:00
machine-sp.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
malloc-alignment.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
malloc-machine.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
malloc-sysdep.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
math-barriers.h Move math_opt_barrier, math_force_eval to separate math-barriers.h. 2018-05-09 19:45:47 +00:00
math-nan-payload-double.h math: Merge strtod_nan_*.h into math-type-macros-*.h 2018-05-16 06:03:08 +02:00
math-nan-payload-float.h math: Merge strtod_nan_*.h into math-type-macros-*.h 2018-05-16 06:03:08 +02:00
math-tests-arch.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
math-tests.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
math-type-macros-double.h math: Reverse include order in <math-type-macros-*.h> 2018-05-17 15:48:42 +02:00
math-type-macros-float.h math: Reverse include order in <math-type-macros-*.h> 2018-05-17 15:48:42 +02:00
math-type-macros-float128.h math: Reverse include order in <math-type-macros-*.h> 2018-05-17 15:48:42 +02:00
math-type-macros-ldouble.h math: Reverse include order in <math-type-macros-*.h> 2018-05-17 15:48:42 +02:00
math-type-macros.h Move declare_mgen_finite_alias definition 2018-06-20 17:42:47 -03:00
math_ldbl.h Allow direct use of math_ldbl.h in testsuite. 2017-02-25 10:40:48 -05:00
math_ldbl_opt.h
math_private.h math: Set 387 and SSE2 rounding mode for tgamma on i386 [BZ #23253] 2018-06-21 08:04:29 +02:00
math_private_calls.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
memcopy.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
memusage.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nan-high-order-bit.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
not-cancel.h Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251) 2018-06-26 13:22:53 -03:00
not-errno.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd-types.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
pagecopy.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
paths.h generic paths.h: remove old paths from _PATH_STDPATH 2012-11-04 10:11:39 +01:00
profil-counter.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
pty-private.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
register-dump.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
rtld-lowlevel.h
safe-fatal.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
setjmpP.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigcontextinfo.h Remove unused frame.h header, sigcontextinfo.h macros. 2018-03-22 16:40:51 +00:00
siglist.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigset-cvt-mask.h hurd: fix warning 2018-01-27 16:45:55 +01:00
sigsetops.h hurd: fix warnings 2018-01-27 16:47:36 +01:00
stackguard-macros.h BZ #15754: Fix test case for ARM. 2013-09-23 01:44:38 -04:00
stackinfo.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
startup.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
stdint.h Define char16_t, char32_t consistently with uint_least16_t, uint_least32_t (bug 17979). 2018-02-07 20:33:55 +00:00
stdio-lock.h Mechanically remove _IO_ name aliases for types and constants. 2018-02-21 14:11:05 -05:00
string_private.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
symbol-hacks.h PLT avoidance for __stack_chk_fail [BZ #7065] 2016-12-26 10:11:05 +01:00
sysdep-cancel.h
sysdep.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
thread_state.h hurd: add TLS support 2018-03-17 03:17:36 +01:00
tininess.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
tls-macros.h
tls.h hurd: add gscope support 2018-03-11 13:06:33 +01:00
tst-audit.h Move testsuite audit definitions to sysdeps tst-audit.h files. 2012-07-26 11:29:07 +00:00
tst-stack-align.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
unsecvars.h Ignore and remove LD_HWCAP_MASK for AT_SECURE programs (bug #21209) 2017-03-07 20:52:04 +05:30
unwind-dw2-fde-glibc.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
unwind-dw2-fde.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
unwind-dw2-fde.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
unwind-dw2.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
unwind-pe.c
unwind-pe.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
unwind-resume.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
unwind.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
utmp-equal.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00