This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.24-75-g6f9d4f5


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  6f9d4f595e4073807ad0e844cbb3b3d7158b76d5 (commit)
      from  b65f0b7b2ecd144800830633a4c2719f11775572 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6f9d4f595e4073807ad0e844cbb3b3d7158b76d5

commit 6f9d4f595e4073807ad0e844cbb3b3d7158b76d5
Author: Torvald Riegel <triegel@redhat.com>
Date:   Wed Aug 17 13:56:11 2016 +0200

    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.

diff --git a/ChangeLog b/ChangeLog
index 59c68d8..bc2c353 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-08-18  Torvald Riegel  <triegel@redhat.com>
+
+	[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.
+
 2016-08-18  Stefan Liebler  <stli@linux.vnet.ibm.com>
 
 	* sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
diff --git a/nscd/aicache.c b/nscd/aicache.c
index a2e6cf8..32c8f57 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;
 
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index 93af253..18d3ad6 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -274,8 +274,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
 	    }
 #endif /* need _res */
 #ifdef NEED__RES_HCONF
-	  if (!_res_hconf.initialized)
-	    _res_hconf_init ();
+	  _res_hconf_init ();
 #endif /* need _res_hconf */
 
 	  void *tmp_ptr = fct.l;
diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c
index 5cd1289..093c268 100644
--- a/resolv/res_hconf.c
+++ b/resolv/res_hconf.c
@@ -348,7 +348,8 @@ do_init (void)
       arg_trimdomain_list (ENV_TRIM_OVERR, 1, envval);
     }
 
-  _res_hconf.initialized = 1;
+  /* See comments on the declaration of _res_hconf.  */
+  atomic_store_release (&_res_hconf.initialized, 1);
 }
 
 
diff --git a/resolv/res_hconf.h b/resolv/res_hconf.h
index b97734d..a3d23f3 100644
--- a/resolv/res_hconf.h
+++ b/resolv/res_hconf.h
@@ -25,6 +25,15 @@
 
 struct hconf
 {
+  /* We keep the INITIALIZED member only for backwards compatibility.  New
+     code should just call _res_hconf_init unconditionally.  For this field
+     to be used safely, users must ensure that either (1) a call to
+     _res_hconf_init happens-before any load from INITIALIZED, or (2) an
+     assignment of zero to INITIALIZED happens-before any load from it, and
+     these loads use acquire MO if the intent is to skip calling
+     _res_hconf_init if the load returns a nonzero value.  Such acquire MO
+     loads will then synchronize with the release MO store to INITIALIZED
+     in do_init in res_hconf.c; see pthread_once for more detail.  */
   int initialized;
   int unused1;
   int unused2[4];
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 574ce08..09fbc83 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -816,8 +816,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 	  nip = __nss_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;
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                   |    9 +++++++++
 nscd/aicache.c              |    3 +--
 nss/getXXbyYY_r.c           |    3 +--
 resolv/res_hconf.c          |    3 ++-
 resolv/res_hconf.h          |    9 +++++++++
 sysdeps/posix/getaddrinfo.c |    3 +--
 6 files changed, 23 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]