glibc/sysdeps
Adhemerval Zanella 8c78faa9ef Fix concurrent changes on nscd aware files (BZ #23178)
As indicated by BZ#23178, concurrent access on some files read by nscd
may result non expected data send through service requisition.  This is
due 'sendfile' Linux implementation where for sockets with zero-copy
support, callers must ensure the transferred portions of the the file
reffered by input file descriptor remain unmodified until the reader
on the other end of socket has consumed the transferred data.

I could not find any explicit documentation stating this behaviour on
Linux kernel documentation.  However man-pages sendfile entry [1] states
in NOTES the aforementioned remark.  It was initially pushed on man-pages
with an explicit testcase [2] that shows changing the file used in
'sendfile' call prior the socket input data consumption results in
previous data being lost.

From commit message it stated on tested Linux version (3.15) only TCP
socket showed this issues, however on recent kernels (4.4) I noticed the
same behaviour for local sockets as well.

Since sendfile on HURD is a read/write operation and the underlying
issue on Linux, the straightforward fix is just remove sendfile use
altogether.  I am really skeptical it is hitting some hotstop (there
are indication over internet that sendfile is helpfull only for large
files, more than 10kb) here to justify that extra code complexity or
to pursuit other possible fix (through memory or file locks for
instance, which I am not sure it is doable).

Checked on x86_64-linux-gnu.

	[BZ #23178]
	* nscd/nscd-client.h (sendfileall): Remove prototype.
	* nscd/connections.c [HAVE_SENDFILE] (sendfileall): Remove function.
	(handle_request): Use writeall instead of sendfileall.
	* nscd/aicache.c (addhstaiX): Likewise.
	* nscd/grpcache.c (cache_addgr): Likewise.
	* nscd/hstcache.c (cache_addhst): Likewise.
	* nscd/initgrcache.c (addinitgroupsX): Likewise.
	* nscd/netgroupcache.c (addgetnetgrentX, addinnetgrX): Likewise.
	* nscd/pwdcache.c (cache_addpw): Likewise.
	* nscd/servicescache.c (cache_addserv): Likewise.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) == nscd]
	(sysdep-CFLAGS): Remove -DHAVE_SENDFILE.
	* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_SENDFILE):
	Remove define.

[1] http://man7.org/linux/man-pages/man2/sendfile.2.html
[2] 7b6a329977 (diff-efd6af3a70f0f07c578e85b51e83b3c3)
2018-05-16 13:44:53 -03:00
..
aarch64 Do not include math-barriers.h in math_private.h. 2018-05-11 15:11:38 +00:00
alpha Move math_opt_barrier, math_force_eval to separate math-barriers.h. 2018-05-09 19:45:47 +00:00
arm Drop fpregset unused symbol exposition 2018-04-20 01:27:13 +02:00
generic math: Merge strtod_nan_*.h into math-type-macros-*.h 2018-05-16 06:03:08 +02:00
gnu Increase robustness of internal dlopen() by using RTLD_NOW [BZ #22766] 2018-04-26 10:41:43 -03:00
hppa R_PARISC_TLS_DTPOFF32 reloc handling 2018-05-13 08:32:28 +09:30
htl hurd: Avoid exposing all <sched.h> symbols from sys/types.h 2018-04-19 20:24:36 +02:00
hurd hurd: Fix hurd installed headers test 2018-04-20 00:16:40 +02:00
i386 Add narrowing multiply functions. 2018-05-16 00:05:28 +00:00
ia64 elf: Unify symbol address run-time calculation [BZ #19818] 2018-04-04 23:09:37 +01:00
ieee754 math: Merge strtod_nan_*.h into math-type-macros-*.h 2018-05-16 06:03:08 +02:00
init_array sysdeps/init_array: Add PREINIT_FUNCTION to crti.S 2018-01-29 10:22:26 -08:00
m68k Do not include math-barriers.h in math_private.h. 2018-05-11 15:11:38 +00:00
mach Add narrowing multiply functions. 2018-05-16 00:05:28 +00:00
microblaze elf: Unify symbol address run-time calculation [BZ #19818] 2018-04-04 23:09:37 +01:00
mips Update MIPS libm-test-ulps. 2018-05-16 15:35:26 +00:00
nios2 Update sysdeps/nios2/libm-test-ulps 2018-04-19 12:00:58 -07:00
nptl Fix comment typo 2018-05-08 14:59:13 +02:00
posix Consolidate Linux readdir{64}{_r} implementation 2018-04-06 17:49:02 -03:00
powerpc Add narrowing multiply functions. 2018-05-16 00:05:28 +00:00
pthread hurd: fix sigevent's sigev_notify_attributes field type 2018-04-19 21:43:44 +02:00
riscv elf: Unify symbol address run-time calculation [BZ #19818] 2018-04-04 23:09:37 +01:00
s390 S390: Regenerate ULPs. 2018-04-05 16:24:06 +02:00
sh elf: Unify symbol address run-time calculation [BZ #19818] 2018-04-04 23:09:37 +01:00
sparc Update SPARC libm-test-ulps. 2018-04-05 17:10:03 -03:00
unix Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00
wordsize-32 Use libc_hidden_* for strtoumax (bug 15105). 2018-02-28 14:16:21 +00:00
wordsize-64 Use libc_hidden_* for strtoumax (bug 15105). 2018-02-28 14:16:21 +00:00
x86 x86: Add sysdeps/x86/ldsodefs.h 2018-05-14 09:19:41 -07:00
x86_64 x86-64: Use IFUNC strncat inside libc.so 2018-05-16 09:04:35 -07:00