glibc/nscd
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
..
Depend hurd: Add hurd thread library 2018-04-02 01:44:14 +02:00
Makefile Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
aicache.c Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00
cache.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
connections.c Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00
dbg_log.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dbg_log.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
gai.c Fix multiple definitions of __nss_*_database (bug 22918) 2018-03-03 17:44:24 +01:00
getgrgid_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
getgrnam_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
gethstbyad_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
gethstbynm3_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
getpwnam_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
getpwuid_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
getsrvbynm_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
getsrvbypt_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
grpcache.c Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00
hstcache.c Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00
initgrcache.c Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00
mem.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
netgroupcache.c Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00
nscd-client.h Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00
nscd.c Update copyright dates not handled by scripts/update-copyrights. 2018-01-01 00:41:16 +00:00
nscd.conf Implement caching of nscd 2011-10-07 10:06:31 -04:00
nscd.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd.init . 2007-07-31 13:33:18 +00:00
nscd.service nscd: also invalidate netgroup cache on reload 2014-03-19 14:45:10 +01:00
nscd.tmpfiles Add systemd unit file for nscd 2013-12-16 11:22:01 +10:00
nscd_conf.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_getai.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_getgr_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_gethst_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_getpw_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_getserv_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_helper.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_initgroups.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_netgroup.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_proto.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_setup_thread.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
nscd_stat.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
pwdcache.c Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00
res_hconf.c [BZ #4814] 2007-08-22 03:14:29 +00:00
selinux.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
selinux.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
servicescache.c Fix concurrent changes on nscd aware files (BZ #23178) 2018-05-16 13:44:53 -03:00