about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-07-26 08:21:54 +0000
committerUlrich Drepper <drepper@redhat.com>2006-07-26 08:21:54 +0000
commit3a975ff5762e4c4368f20f7b7e2ed0982ee9332a (patch)
tree81af55ae7db1b70fb9382297231f9d5700e7477a
parenta92b1166e524c44266493c972c89191d52f5c604 (diff)
downloadglibc-3a975ff5762e4c4368f20f7b7e2ed0982ee9332a.tar.gz
glibc-3a975ff5762e4c4368f20f7b7e2ed0982ee9332a.tar.xz
glibc-3a975ff5762e4c4368f20f7b7e2ed0982ee9332a.zip
* dlfcn/dlmopen.c (dlmopen_doit): Don't allow RTLD_GLOBAL to be
	used when the namespace is not the base namespace.
-rw-r--r--ChangeLog5
-rw-r--r--dlfcn/dlmopen.c17
2 files changed, 17 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index fde42b3dfa..2852fb1fdf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-26  Ulrich Drepper  <drepper@redhat.com>
+
+	* dlfcn/dlmopen.c (dlmopen_doit): Don't allow RTLD_GLOBAL to be
+	used when the namespace is not the base namespace.
+
 2006-07-26  Gavin Romig-Koch  <gavin@redhat.com>
 
 	* stdlib/cxa_atexit.c (__new_exitfn_called): New variable.
diff --git a/dlfcn/dlmopen.c b/dlfcn/dlmopen.c
index 0a6d47ea2e..0c6915493b 100644
--- a/dlfcn/dlmopen.c
+++ b/dlfcn/dlmopen.c
@@ -1,5 +1,5 @@
 /* Load a shared object at run time.
-   Copyright (C) 1995,96,97,98,99,2000,2003,2004 Free Software Foundation, Inc.
+   Copyright (C) 1995-2000,2003,2004,2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -55,12 +55,19 @@ dlmopen_doit (void *a)
 
   /* Non-shared code has no support for multiple namespaces.  */
   if (args->nsid != LM_ID_BASE)
+    {
 # ifdef SHARED
-    /* If trying to open the link map for the main executable the namespace
-       must be the main one.  */
-    if (args->file == NULL)
+      /* If trying to open the link map for the main executable the namespace
+	 must be the main one.  */
+      if (args->file == NULL)
 # endif
-      GLRO(dl_signal_error) (EINVAL, NULL, NULL, N_("invalid namespace"));
+	GLRO(dl_signal_error) (EINVAL, NULL, NULL, N_("invalid namespace"));
+
+      /* It makes no sense to use RTLD_GLOBAL when loading a DSO into
+	 a namespace other than the base namespace.  */
+      if (__builtin_expect (args->mode & RTLD_GLOBAL, 0))
+	GLRO(dl_signal_error) (EINVAL, NULL, NULL, N_("invalid mode"));
+    }
 
   args->new = GLRO(dl_open) (args->file ?: "", args->mode | __RTLD_DLOPEN,
 			     args->caller,