From 6f9d4f595e4073807ad0e844cbb3b3d7158b76d5 Mon Sep 17 00:00:00 2001 From: Torvald Riegel Date: Wed, 17 Aug 2016 13:56:11 +0200 Subject: Fix incorrect double-checked locking related to _res_hconf.initialized. _res_hconf.initialized was not suitable for use in a multi-threaded environment due to the lack of atomics and memory barriers. Use of it was also unnecessary because _res_hconf_init did the right thing by using __libc_once. This patch fixes the glibc-internal uses by just calling _res_hconf_init unconditionally, and switches to a release MO atomic store for _res_hconf.initialized to fix the glibc side of the synchronization problem (which will maintain backward compatibility, but cannot fix the lack of acquire MO on any glibc-external loads). [BZ #20477] * resolv/res_hconf.c (do_init): Use atomic access. * resolv/res_hconf.h: Add comments. * nscd/aicache.c (addhstaiX): Call _res_hconf_init unconditionally. * nss/getXXbyYY_r.c (REENTRANT_NAME): Likewise. * sysdeps/posix/getaddrinfo.c (gaih_inet): Likewise. --- nscd/aicache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'nscd') diff --git a/nscd/aicache.c b/nscd/aicache.c index a2e6cf8475..32c8f57b41 100644 --- a/nscd/aicache.c +++ b/nscd/aicache.c @@ -101,8 +101,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, nip = hosts_database; /* Initialize configurations. */ - if (__glibc_unlikely (!_res_hconf.initialized)) - _res_hconf_init (); + _res_hconf_init (); if (__res_maybe_init (&_res, 0) == -1) no_more = 1; -- cgit v1.2.3