]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/glibc/glibc-rh645672.patch
Merge remote-tracking branch 'origin/next' into thirteen
[people/pmueller/ipfire-2.x.git] / src / patches / glibc / glibc-rh645672.patch
1 2010-10-22 Andreas Schwab <schwab@redhat.com>
2
3 * include/dlfcn.h (__RTLD_SECURE): Define.
4 * elf/dl-load.c (_dl_map_object): Remove preloaded parameter. Use
5 mode & __RTLD_SECURE instead.
6 (open_path): Remove preloaded parameter to secure.
7 * sysdeps/generic/ldsodefs.h (_dl_map_object): Adjust declaration.
8 * elf/dl-open.c (dl_open_worker): Adjust call to _dl_map_object.
9 * elf/dl-deps.c (openaux): Likewise.
10 * elf/rtld.c (struct map_args): Remove is_preloaded.
11 (map_doit): Don't use it.
12 (dl_main): Likewise.
13 (do_preload): Use __RTLD_SECURE instead of is_preloaded.
14 (dlmopen_doit): Add __RTLD_SECURE to mode bits.
15
16 Index: glibc-2.12-2-gc4ccff1/elf/dl-deps.c
17 ===================================================================
18 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-deps.c
19 +++ glibc-2.12-2-gc4ccff1/elf/dl-deps.c
20 @@ -62,7 +62,7 @@ openaux (void *a)
21 {
22 struct openaux_args *args = (struct openaux_args *) a;
23
24 - args->aux = _dl_map_object (args->map, args->name, 0,
25 + args->aux = _dl_map_object (args->map, args->name,
26 (args->map->l_type == lt_executable
27 ? lt_library : args->map->l_type),
28 args->trace_mode, args->open_mode,
29 Index: glibc-2.12-2-gc4ccff1/elf/dl-load.c
30 ===================================================================
31 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-load.c
32 +++ glibc-2.12-2-gc4ccff1/elf/dl-load.c
33 @@ -1811,7 +1811,7 @@ open_verify (const char *name, struct fi
34 if MAY_FREE_DIRS is true. */
35
36 static int
37 -open_path (const char *name, size_t namelen, int preloaded,
38 +open_path (const char *name, size_t namelen, int secure,
39 struct r_search_path_struct *sps, char **realname,
40 struct filebuf *fbp, struct link_map *loader, int whatcode,
41 bool *found_other_class)
42 @@ -1893,7 +1893,7 @@ open_path (const char *name, size_t name
43 /* Remember whether we found any existing directory. */
44 here_any |= this_dir->status[cnt] != nonexisting;
45
46 - if (fd != -1 && __builtin_expect (preloaded, 0)
47 + if (fd != -1 && __builtin_expect (secure, 0)
48 && INTUSE(__libc_enable_secure))
49 {
50 /* This is an extra security effort to make sure nobody can
51 @@ -1962,7 +1962,7 @@ open_path (const char *name, size_t name
52
53 struct link_map *
54 internal_function
55 -_dl_map_object (struct link_map *loader, const char *name, int preloaded,
56 +_dl_map_object (struct link_map *loader, const char *name,
57 int type, int trace_mode, int mode, Lmid_t nsid)
58 {
59 int fd;
60 @@ -2066,7 +2066,8 @@ _dl_map_object (struct link_map *loader,
61 for (l = loader; l; l = l->l_loader)
62 if (cache_rpath (l, &l->l_rpath_dirs, DT_RPATH, "RPATH"))
63 {
64 - fd = open_path (name, namelen, preloaded, &l->l_rpath_dirs,
65 + fd = open_path (name, namelen, mode & __RTLD_SECURE,
66 + &l->l_rpath_dirs,
67 &realname, &fb, loader, LA_SER_RUNPATH,
68 &found_other_class);
69 if (fd != -1)
70 @@ -2081,14 +2082,15 @@ _dl_map_object (struct link_map *loader,
71 && main_map != NULL && main_map->l_type != lt_loaded
72 && cache_rpath (main_map, &main_map->l_rpath_dirs, DT_RPATH,
73 "RPATH"))
74 - fd = open_path (name, namelen, preloaded, &main_map->l_rpath_dirs,
75 + fd = open_path (name, namelen, mode & __RTLD_SECURE,
76 + &main_map->l_rpath_dirs,
77 &realname, &fb, loader ?: main_map, LA_SER_RUNPATH,
78 &found_other_class);
79 }
80
81 /* Try the LD_LIBRARY_PATH environment variable. */
82 if (fd == -1 && env_path_list.dirs != (void *) -1)
83 - fd = open_path (name, namelen, preloaded, &env_path_list,
84 + fd = open_path (name, namelen, mode & __RTLD_SECURE, &env_path_list,
85 &realname, &fb,
86 loader ?: GL(dl_ns)[LM_ID_BASE]._ns_loaded,
87 LA_SER_LIBPATH, &found_other_class);
88 @@ -2097,12 +2099,12 @@ _dl_map_object (struct link_map *loader,
89 if (fd == -1 && loader != NULL
90 && cache_rpath (loader, &loader->l_runpath_dirs,
91 DT_RUNPATH, "RUNPATH"))
92 - fd = open_path (name, namelen, preloaded,
93 + fd = open_path (name, namelen, mode & __RTLD_SECURE,
94 &loader->l_runpath_dirs, &realname, &fb, loader,
95 LA_SER_RUNPATH, &found_other_class);
96
97 if (fd == -1
98 - && (__builtin_expect (! preloaded, 1)
99 + && (__builtin_expect (! (mode & __RTLD_SECURE), 1)
100 || ! INTUSE(__libc_enable_secure)))
101 {
102 /* Check the list of libraries in the file /etc/ld.so.cache,
103 @@ -2168,7 +2170,7 @@ _dl_map_object (struct link_map *loader,
104 && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL
105 || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1))
106 && rtld_search_dirs.dirs != (void *) -1)
107 - fd = open_path (name, namelen, preloaded, &rtld_search_dirs,
108 + fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs,
109 &realname, &fb, l, LA_SER_DEFAULT, &found_other_class);
110
111 /* Add another newline when we are tracing the library loading. */
112 Index: glibc-2.12-2-gc4ccff1/elf/dl-open.c
113 ===================================================================
114 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-open.c
115 +++ glibc-2.12-2-gc4ccff1/elf/dl-open.c
116 @@ -252,7 +252,7 @@ dl_open_worker (void *a)
117
118 /* Load the named object. */
119 struct link_map *new;
120 - args->map = new = _dl_map_object (call_map, file, 0, lt_loaded, 0,
121 + args->map = new = _dl_map_object (call_map, file, lt_loaded, 0,
122 mode | __RTLD_CALLMAP, args->nsid);
123
124 /* If the pointer returned is NULL this means the RTLD_NOLOAD flag is
125 Index: glibc-2.12-2-gc4ccff1/elf/rtld.c
126 ===================================================================
127 --- glibc-2.12-2-gc4ccff1.orig/elf/rtld.c
128 +++ glibc-2.12-2-gc4ccff1/elf/rtld.c
129 @@ -589,7 +589,6 @@ struct map_args
130 /* Argument to map_doit. */
131 char *str;
132 struct link_map *loader;
133 - int is_preloaded;
134 int mode;
135 /* Return value of map_doit. */
136 struct link_map *map;
137 @@ -627,16 +626,17 @@ static void
138 map_doit (void *a)
139 {
140 struct map_args *args = (struct map_args *) a;
141 - args->map = _dl_map_object (args->loader, args->str,
142 - args->is_preloaded, lt_library, 0, args->mode,
143 - LM_ID_BASE);
144 + args->map = _dl_map_object (args->loader, args->str, lt_library, 0,
145 + args->mode, LM_ID_BASE);
146 }
147
148 static void
149 dlmopen_doit (void *a)
150 {
151 struct dlmopen_args *args = (struct dlmopen_args *) a;
152 - args->map = _dl_open (args->fname, RTLD_LAZY | __RTLD_DLOPEN | __RTLD_AUDIT,
153 + args->map = _dl_open (args->fname,
154 + (RTLD_LAZY | __RTLD_DLOPEN | __RTLD_AUDIT
155 + | __RTLD_SECURE),
156 dl_main, LM_ID_NEWLM, _dl_argc, INTUSE(_dl_argv),
157 __environ);
158 }
159 @@ -806,8 +806,7 @@ do_preload (char *fname, struct link_map
160
161 args.str = fname;
162 args.loader = main_map;
163 - args.is_preloaded = 1;
164 - args.mode = 0;
165 + args.mode = __RTLD_SECURE;
166
167 unsigned int old_nloaded = GL(dl_ns)[LM_ID_BASE]._ns_nloaded;
168
169 @@ -1054,7 +1053,6 @@ of this helper program; chances are you
170
171 args.str = rtld_progname;
172 args.loader = NULL;
173 - args.is_preloaded = 0;
174 args.mode = __RTLD_OPENEXEC;
175 (void) _dl_catch_error (&objname, &err_str, &malloced, map_doit,
176 &args);
177 @@ -1066,7 +1064,7 @@ of this helper program; chances are you
178 else
179 {
180 HP_TIMING_NOW (start);
181 - _dl_map_object (NULL, rtld_progname, 0, lt_library, 0,
182 + _dl_map_object (NULL, rtld_progname, lt_library, 0,
183 __RTLD_OPENEXEC, LM_ID_BASE);
184 HP_TIMING_NOW (stop);
185
186 Index: glibc-2.12-2-gc4ccff1/include/dlfcn.h
187 ===================================================================
188 --- glibc-2.12-2-gc4ccff1.orig/include/dlfcn.h
189 +++ glibc-2.12-2-gc4ccff1/include/dlfcn.h
190 @@ -9,6 +9,7 @@
191 #define __RTLD_OPENEXEC 0x20000000
192 #define __RTLD_CALLMAP 0x10000000
193 #define __RTLD_AUDIT 0x08000000
194 +#define __RTLD_SECURE 0x04000000 /* Apply additional security checks. */
195
196 #define __LM_ID_CALLER -2
197
198 Index: glibc-2.12-2-gc4ccff1/sysdeps/generic/ldsodefs.h
199 ===================================================================
200 --- glibc-2.12-2-gc4ccff1.orig/sysdeps/generic/ldsodefs.h
201 +++ glibc-2.12-2-gc4ccff1/sysdeps/generic/ldsodefs.h
202 @@ -824,11 +824,9 @@ extern void _dl_receive_error (receiver_
203
204 /* Open the shared object NAME and map in its segments.
205 LOADER's DT_RPATH is used in searching for NAME.
206 - If the object is already opened, returns its existing map.
207 - For preloaded shared objects PRELOADED is set to a non-zero
208 - value to allow additional security checks. */
209 + If the object is already opened, returns its existing map. */
210 extern struct link_map *_dl_map_object (struct link_map *loader,
211 - const char *name, int preloaded,
212 + const char *name,
213 int type, int trace_mode, int mode,
214 Lmid_t nsid)
215 internal_function attribute_hidden;