-
Notifications
You must be signed in to change notification settings - Fork 1
/
glibc-2.22-roundup.patch
2747 lines (2642 loc) · 87.5 KB
/
glibc-2.22-roundup.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/ChangeLog b/ChangeLog
index cb9124e..376355f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,300 @@
+2016-02-12 Florian Weimer <[email protected]>
+
+ * misc/bug18240.c (do_test): Set RLIMIT_AS.
+
+2016-01-27 Paul Eggert <[email protected]>
+
+ [BZ #18240]
+ * misc/hsearch_r.c (isprime, __hcreate_r): Protect against
+ unsigned int wraparound.
+
+2016-01-27 Florian Weimer <[email protected]>
+
+ [BZ #18240]
+ * misc/bug18240.c: New test.
+ * misc/Makefile (tests): Add it.
+
+2015-08-25 Ondřej Bílka <[email protected]>
+
+ [BZ #18240]
+ * misc/hsearch_r.c (__hcreate_r): Handle overflow.
+
+2015-10-27 Ludovic Courtès <[email protected]>
+
+ * locale/loadlocale.c (_nl_intern_locale_data): Change assertion
+ on CNT to a conditional jump to 'puntdata'.
+
+2015-08-18 Alan Modra <[email protected]>
+
+ [BZ #18421]
+ * sysdeps/hppa/start.S [SHARED]: Use .section .data.rel.ro and define
+ .Lp__global.
+ (_start): Load %dp via .Lp__global.
+ [!SHARED]: Use .section .rodata.
+
+2015-08-09 John David Anglin <[email protected]>
+
+ [BZ #18480]
+ * sysdeps/unix/sysv/linux/hppa/sysdep.h (LOAD_ARGS_0, LOAD_ARGS_1,
+ LOAD_ARGS_2, LOAD_ARGS_3, LOAD_ARGS_4, LOAD_ARGS_5, LOAD_ARGS_6):
+ Define.
+ (LOAD_REGS_0, LOAD_REGS_1, LOAD_REGS_2, LOAD_REGS_3, LOAD_REGS_4,
+ LOAD_REGS_5, LOAD_REGS_6): Update.
+ (INTERNAL_SYSCALL): Update using new LOAD defines.
+ (INTERNAL_SYSCALL_NCS): Likewise.
+ * sysdeps/unix/sysv/linux/hppa/syscall.c (syscall): Likewise.
+
+2015-09-26 Paul Pluzhnikov <[email protected]>
+
+ [BZ #18985]
+ * time/strftime_l.c (a_wkday, f_wkday, a_month, f_month): Range check.
+ (__strftime_internal): Likewise.
+ * time/tst-strftime.c (do_bz18985): New test.
+ (do_test): Call it.
+
+2015-08-08 Paul Pluzhnikov <[email protected]>
+
+ [BZ #17905]
+ * catgets/Makefile (tst-catgets-mem): New test.
+ * catgets/catgets.c (catopen): Don't use unbounded alloca.
+ * catgets/open_catalog.c (__open_catalog): Likewise.
+ * catgets/tst-catgets.c (do_bz17905): Test unbounded alloca.
+
+2015-12-31 Aurelien Jarno <[email protected]>
+
+ * sysdeps/unix/sysv/linux/alpha/libc.abilist [GLIBC_2.22]: Move
+ to keep the file sorted.
+ * sysdeps/unix/sysv/linux/hppa/libc.abilist [GLIBC_2.22]: Likewise.
+
+2015-12-17 Paul E. Murphy <[email protected]>
+
+ [BZ #19174]
+ * sysdeps/powerpc/nptl/elide.h (__elide_lock): Fix usage of
+ .skip_lock_out_of_tbegin_retries.
+ * sysdeps/unix/sysv/linux/powerpc/elision-lock.c
+ (__lll_lock_elision): Likewise, and respect a value of
+ try_tbegin <= 0.
+
+2015-11-20 Roland McGrath <[email protected]>
+
+ * sysdeps/nacl/dl-map-segments.h (_dl_map_segments): Use
+ __glibc_likely instead of __builtin_expect. After falling back to
+ dyncode_create in a non-ET_DYN case, use the allocate_code_data
+ system interface to register the code pages as occupied.
+
+2015-11-14 H.J. Lu <[email protected]>
+
+ * config.make.in (have-glob-dat-reloc): New.
+ * configure.ac (libc_cv_has_glob_dat): New. Set to yes if
+ target supports GLOB_DAT relocaton. AC_SUBST.
+ * configure: Regenerated.
+ * elf/Makefile (tests): Add tst-prelink.
+ (tests-special): Add $(objpfx)tst-prelink-cmp.out.
+ (tst-prelink-ENV): New.
+ ($(objpfx)tst-prelink-conflict.out): Likewise.
+ ($(objpfx)tst-prelink-cmp.out): Likewise.
+ * sysdeps/x86/tst-prelink.c: Moved to ...
+ * elf/tst-prelink.c: Here.
+ * sysdeps/x86/tst-prelink.exp: Moved to ...
+ * elf/tst-prelink.exp: Here.
+ * sysdeps/x86/Makefile (tests): Don't add tst-prelink.
+ (tst-prelink-ENV): Removed.
+ ($(objpfx)tst-prelink-conflict.out): Likewise.
+ ($(objpfx)tst-prelink-cmp.out): Likewise.
+ (tests-special): Don't add $(objpfx)tst-prelink-cmp.out.
+
+2015-11-10 Roland McGrath <[email protected]>
+
+ * elf/dl-load.c (open_verify): Take new argument FD.
+ Skip __open call if passed FD is not -1.
+ (_dl_map_object, open_path): Update callers.
+ * elf/dl-sysdep-open.h: New file.
+ * elf/dl-load.c: Include it.
+ (_dl_map_object): Try _dl_sysdep_open_object before ldconfig cache.
+ * sysdeps/nacl/dl-sysdep.c (_dl_sysdep_open_object): New function.
+ * sysdeps/nacl/dl-sysdep-open.h: New file.
+ * sysdeps/nacl/nacl-interface-list.h: Move nacl_irt_resource_open
+ from libc to rtld.
+
+2015-11-10 H.J. Lu <[email protected]>
+
+ [BZ #19178]
+ * sysdeps/x86/Makefile (tests): Add tst-prelink.
+ (tst-prelink-ENV): New.
+ ($(objpfx)tst-prelink-conflict.out): Likewise.
+ ($(objpfx)tst-prelink-cmp.out): Likewise.
+ (tests-special): Add $(objpfx)tst-prelink-cmp.out.
+ * sysdeps/x86/tst-prelink.c: New file.
+ * sysdeps/x86/tst-prelink.exp: Likewise.
+
+2015-11-07 H.J. Lu <[email protected]>
+
+ [BZ #19178]
+ * elf/dl-lookup.c (RTYPE_CLASS_VALID): New.
+ (RTYPE_CLASS_PLT): Likewise.
+ (RTYPE_CLASS_COPY): Likewise.
+ (RTYPE_CLASS_TLS): Likewise.
+ (_dl_debug_bindings): Use RTYPE_CLASS_TLS and RTYPE_CLASS_VALID
+ to set relocation type class for DL_DEBUG_PRELINK. Keep only
+ ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY bits for
+ DL_DEBUG_PRELINK.
+
+2015-10-20 Tulio Magno Quites Machado Filho <[email protected]>
+
+ [BZ #18743]
+ * sysdeps/powerpc/nptl/elide.h (__elide_lock): Move most of this
+ code to...
+ (ELIDE_LOCK): ...here.
+ (__get_new_count): New function with part of the code from
+ __elide_lock that updates the value of adapt_count after a
+ transaction abort.
+ (__elided_trylock): Moved this code to...
+ (ELIDE_TRYLOCK): ...here.
+
+2015-10-06 Florian Weimer <[email protected]>
+
+ [BZ #19018]
+ * stdlib/cxa_thread_atexit_impl.c (__cxa_thread_atexit_impl):
+ Mangle function pointer before storing it.
+ (__call_tls_dtors): Demangle function pointer before calling it.
+
+2015-10-15 Florian Weimer <[email protected]>
+
+ [BZ #18928]
+ * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Remove
+ _dl_pointer_guard member.
+ * elf/rtld.c (_rtld_global_ro): Remove _dl_pointer_guard
+ initializer.
+ (security_init): Always set up pointer guard.
+ (process_envvars): Do not process LD_POINTER_GUARD.
+
+2015-10-09 Carlos O'Donell <[email protected]>
+
+ [BZ #18589]
+ * string/bug-strcoll2.c: Adjust copyright, and remove contributed by.
+ * string/Makefile ($(objpfx)bug-strcoll2.out): Depend on
+ $(gen-locales).
+
+2015-10-08 Carlos O'Donell <[email protected]>
+
+ [BZ #18589]
+ * string/Makefile (tests): Add bug-strcoll2.
+ (LOCALES): Add cs_CZ.UTF-8.
+
+2015-09-28 Martin Sebor <[email protected]>
+
+ [BZ #18969]
+ * string/Makefile (LOCALES): Define.
+ (gen-locales.mk): Include.
+ (test-strcasecmp.out, test-strncasecmp.out, tst-strxfrm.out)
+ (tst-strxfrm2.out): Add deppendency on $(gen-locales).
+ * string/tst-strxfrm2.c (do_test): Print the name of the locale
+ on setlocale failure.
+
+2015-10-08 Carlos O'Donell <[email protected]>
+
+ [BZ #18589]
+ * string/bug-strcoll2.c: New file.
+ * locale/categories.def: Revert commit
+ f13c2a8dff2329c6692a80176262ceaaf8a6f74e.
+ * locale/langinfo.h: Likewise.
+ * locale/localeinfo.h: Likewise.
+ * locale/C-collate.c: Likewise.
+ * programs/ld-collate.c (collate_output): Likewise.
+ * string/strcoll_l.c (STRDIFF): Likewise.
+ (STRCOLL): Likewise.
+ * wcsmbs/wcscoll_l.c: Likewise.
+
+2015-09-15 Roland McGrath <[email protected]>
+
+ * misc/sys/param.h [!MAXHOSTNAMELEN && HOST_NAME_MAX]
+ (MAXHOSTNAMELEN): Define it to HOST_NAME_MAX.
+
+2015-09-11 Roland McGrath <[email protected]>
+
+ * sysdeps/nacl/Makefile [$(subdir) = misc] (sysdep_headers):
+ Use 'override' keyword to freeze the value here, preventing
+ the addition of sys/mtio.h by sysdeps/gnu/Makefile.
+
+2015-09-04 Roland McGrath <[email protected]>
+
+ [BZ #18921]
+ * sysdeps/posix/opendir.c (need_isdir_precheck) [O_DIRECTORY]:
+ Fix inverted sense of test of 'o_directory_works' value.
+ Reported by Pádraig Brady <[email protected]>, diagnosed by
+ Bernhard Voelker <[email protected]>.
+
+2015-08-31 Brett Neumeier <[email protected]>
+
+ [BZ #18870]
+ * sysdeps/sparc/sparc32/sem_open.c: Add missing #include
+
+2015-08-28 Mike Frysinger <[email protected]>
+
+ [BZ #18887]
+ * misc/Makefile (tests): Add tst-mntent-blank-corrupt and
+ tst-mntent-blank-passno.
+ * misc/mntent_r.c (__getmntent_r): Do not read past buffer[0].
+ * misc/tst-mntent-blank-corrupt.c: New test.
+ * misc/tst-mntent-blank-passno.c: New test ripped from ...
+ * misc/tst-mntent.c (do_test): ... here.
+
+2015-08-25 Roland McGrath <[email protected]>
+
+ * sysdeps/nacl/start.c (_start): Call __nacl_main instead of main
+ if the weak reference is not null.
+
+2015-08-19 Andrew Senkevich <[email protected]>
+
+ [BZ #18796]
+ * scripts/test-installation.pl: Don't add -lmvec to build options
+ if libmvec wasn't built.
+ * NEWS: Mention this fix.
+
+2015-08-10 Maxim Ostapenko <[email protected]>
+
+ [BZ #18778]
+ * elf/Makefile (tests): Add Add tst-nodelete2.
+ (modules-names): Add tst-nodelete2mod.
+ (tst-nodelete2mod.so-no-z-defs): New.
+ ($(objpfx)tst-nodelete2): Likewise.
+ ($(objpfx)tst-nodelete2.out): Likewise.
+ (LDFLAGS-tst-nodelete2): Likewise.
+ * elf/dl-close.c (_dl_close_worker): Move DF_1_NODELETE clearing
+ out of loop through all loaded libraries.
+ * elf/tst-nodelete2.c: New file.
+ * elf/tst-nodelete2mod.c: Likewise.
+
+2015-08-10 Andreas Schwab <[email protected]>
+
+ [BZ #18781]
+ * sysdeps/unix/sysv/linux/openat.c (__OPENAT) [MORE_OFLAGS]: Add
+ MORE_OFLAGS to oflag.
+ * io/test-lfs.c (do_test): Test openat64.
+
+2015-08-08 John David Anglin <[email protected]>
+
+ [BZ #18787]
+ * sysdeps/unix/sysv/linux/hppa/bits/atomic.h (_LWS_CLOBBER): Revise
+ clobber registers.
+ (atomic_compare_and_exchange_val_acq): Use register asms to assign
+ operand registers. Use register %r20 for EAGAIN and EDEADLOCK checks.
+ Cast return to __typeof (oldval).
+
+2015-08-08 Mike Frysinger <[email protected]>
+
+ * sysdeps/unix/sysv/linux/microblaze/sysdep.h: Wrap the whole file
+ in _LINUX_MICROBLAZE_SYSDEP_H defines. Include sysdeps/unix/sysdep.h
+ and delete sys/syscall.h include.
+
+2015-08-07 Mike Frysinger <[email protected]>
+
+ * sysdeps/hppa/dl-symaddr.c (_dl_symbol_address): Add rtld_hidden_def.
+
+2015-08-05 Zack Weinberg <[email protected]>
+
+ * misc/regexp.h: Update comments.
+
2015-08-05 Carlos O'Donell <[email protected]>
* version.h (RELEASE): Set to "stable".
diff --git a/NEWS b/NEWS
index 4c31de7..7c4fbc6 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,16 @@ See the end for copying conditions.
Please send GNU C library bug reports via <http://sourceware.org/bugzilla/>
using `glibc' in the "product" field.
+Version 2.22.1
+
+* The following bugs are resolved with this release:
+
+ 17905, 18420, 18421, 18480, 18589, 18743, 18778, 18781, 18787, 18796,
+ 18870, 18887, 18921, 18928, 18969, 18985, 19018, 19174, 19178.
+
+* The LD_POINTER_GUARD environment variable can no longer be used to
+ disable the pointer guard feature. It is always enabled.
+
Version 2.22
* The following bugs are resolved with this release:
@@ -84,7 +94,7 @@ Version 2.22
release. Use of this header will trigger a deprecation warning.
Application developers should update their code to use <regex.h> instead.
- This header was formerly part of SUSv2, but was deprecated in 1997 and
+ This header was formerly part of SUS, but was deprecated in 1994 and
removed from the standard in 2001. Also, the glibc implementation
leaks memory. See BZ#18681 for more details.
diff --git a/catgets/Makefile b/catgets/Makefile
index 4624a88..56de38b 100644
--- a/catgets/Makefile
+++ b/catgets/Makefile
@@ -34,6 +34,7 @@ test-srcs = test-gencat
ifeq ($(run-built-tests),yes)
tests-special += $(objpfx)de/libc.cat $(objpfx)test1.cat $(objpfx)test2.cat \
$(objpfx)sample.SJIS.cat $(objpfx)test-gencat.out
+tests-special += $(objpfx)tst-catgets-mem.out
endif
gencat-modules = xmalloc
@@ -50,9 +51,11 @@ catgets-CPPFLAGS := -DNLSPATH='"$(msgcatdir)/%L/%N:$(msgcatdir)/%L/LC_MESSAGES/%
generated += de.msg test1.cat test1.h test2.cat test2.h sample.SJIS.cat \
test-gencat.h
+generated += tst-catgets.mtrace tst-catgets-mem.out
+
generated-dirs += de
-tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de
+tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de MALLOC_TRACE=$(objpfx)tst-catgets.mtrace
ifeq ($(run-built-tests),yes)
# This test just checks whether the program produces any error or not.
@@ -86,4 +89,8 @@ $(objpfx)test-gencat.out: test-gencat.sh $(objpfx)test-gencat \
$(objpfx)sample.SJIS.cat: sample.SJIS $(objpfx)gencat
$(built-program-cmd) -H $(objpfx)test-gencat.h < $(word 1,$^) > $@; \
$(evaluate-test)
+
+$(objpfx)tst-catgets-mem.out: $(objpfx)tst-catgets.out
+ $(common-objpfx)malloc/mtrace $(objpfx)tst-catgets.mtrace > $@; \
+ $(evaluate-test)
endif
diff --git a/catgets/catgets.c b/catgets/catgets.c
index cf93d56..4be452d 100644
--- a/catgets/catgets.c
+++ b/catgets/catgets.c
@@ -16,7 +16,6 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <alloca.h>
#include <errno.h>
#include <locale.h>
#include <nl_types.h>
@@ -35,6 +34,7 @@ catopen (const char *cat_name, int flag)
__nl_catd result;
const char *env_var = NULL;
const char *nlspath = NULL;
+ char *tmp = NULL;
if (strchr (cat_name, '/') == NULL)
{
@@ -54,7 +54,10 @@ catopen (const char *cat_name, int flag)
{
/* Append the system dependent directory. */
size_t len = strlen (nlspath) + 1 + sizeof NLSPATH;
- char *tmp = alloca (len);
+ tmp = malloc (len);
+
+ if (__glibc_unlikely (tmp == NULL))
+ return (nl_catd) -1;
__stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH);
nlspath = tmp;
@@ -65,16 +68,18 @@ catopen (const char *cat_name, int flag)
result = (__nl_catd) malloc (sizeof (*result));
if (result == NULL)
- /* We cannot get enough memory. */
- return (nl_catd) -1;
-
- if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
+ {
+ /* We cannot get enough memory. */
+ result = (nl_catd) -1;
+ }
+ else if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
{
/* Couldn't open the file. */
free ((void *) result);
- return (nl_catd) -1;
+ result = (nl_catd) -1;
}
+ free (tmp);
return (nl_catd) result;
}
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index e069416..9f4d776 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -47,6 +47,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
size_t tab_size;
const char *lastp;
int result = -1;
+ char *buf = NULL;
if (strchr (cat_name, '/') != NULL || nlspath == NULL)
fd = open_not_cancel_2 (cat_name, O_RDONLY);
@@ -57,23 +58,23 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
if (__glibc_unlikely (bufact + (n) >= bufmax)) \
{ \
char *old_buf = buf; \
- bufmax += 256 + (n); \
- buf = (char *) alloca (bufmax); \
- memcpy (buf, old_buf, bufact); \
+ bufmax += (bufmax < 256 + (n)) ? 256 + (n) : bufmax; \
+ buf = realloc (buf, bufmax); \
+ if (__glibc_unlikely (buf == NULL)) \
+ { \
+ free (old_buf); \
+ return -1; \
+ } \
}
/* The RUN_NLSPATH variable contains a colon separated list of
descriptions where we expect to find catalogs. We have to
recognize certain % substitutions and stop when we found the
first existing file. */
- char *buf;
size_t bufact;
- size_t bufmax;
+ size_t bufmax = 0;
size_t len;
- buf = NULL;
- bufmax = 0;
-
fd = -1;
while (*run_nlspath != '\0')
{
@@ -188,7 +189,10 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
/* Avoid dealing with directories and block devices */
if (__builtin_expect (fd, 0) < 0)
- return -1;
+ {
+ free (buf);
+ return -1;
+ }
if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
goto close_unlock_return;
@@ -325,6 +329,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
/* Release the lock again. */
close_unlock_return:
close_not_cancel_no_status (fd);
+ free (buf);
return result;
}
diff --git a/catgets/tst-catgets.c b/catgets/tst-catgets.c
index a0a4089..0886938 100644
--- a/catgets/tst-catgets.c
+++ b/catgets/tst-catgets.c
@@ -1,7 +1,10 @@
+#include <assert.h>
#include <mcheck.h>
#include <nl_types.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <sys/resource.h>
static const char *msgs[] =
@@ -12,6 +15,33 @@ static const char *msgs[] =
};
#define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
+
+/* Test for unbounded alloca. */
+static int
+do_bz17905 (void)
+{
+ char *buf;
+ struct rlimit rl;
+ nl_catd result;
+
+ const int sz = 1024 * 1024;
+
+ getrlimit (RLIMIT_STACK, &rl);
+ rl.rlim_cur = sz;
+ setrlimit (RLIMIT_STACK, &rl);
+
+ buf = malloc (sz + 1);
+ memset (buf, 'A', sz);
+ buf[sz] = '\0';
+ setenv ("NLSPATH", buf, 1);
+
+ result = catopen (buf, NL_CAT_LOCALE);
+ assert (result == (nl_catd) -1);
+
+ free (buf);
+ return 0;
+}
+
#define ROUNDS 5
static int
@@ -62,6 +92,7 @@ do_test (void)
}
}
+ result += do_bz17905 ();
return result;
}
diff --git a/config.make.in b/config.make.in
index a9f5696..46cd9bb 100644
--- a/config.make.in
+++ b/config.make.in
@@ -51,6 +51,7 @@ have-z-combreloc = @libc_cv_z_combreloc@
have-z-execstack = @libc_cv_z_execstack@
have-Bgroup = @libc_cv_Bgroup@
have-protected-data = @libc_cv_protected_data@
+have-glob-dat-reloc = @libc_cv_has_glob_dat@
with-fp = @with_fp@
old-glibc-headers = @old_glibc_headers@
unwind-find-fde = @libc_cv_gcc_unwind_find_fde@
diff --git a/configure b/configure
index 45cc7cb..4f87b31 100755
--- a/configure
+++ b/configure
@@ -628,6 +628,7 @@ gnu89_inline
libc_cv_ssp
fno_unit_at_a_time
libc_cv_output_format
+libc_cv_has_glob_dat
libc_cv_hashstyle
libc_cv_fpie
libc_cv_z_execstack
@@ -6335,6 +6336,39 @@ $as_echo "$libc_cv_use_default_link" >&6; }
use_default_link=$libc_cv_use_default_link
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
+$as_echo_n "checking for GLOB_DAT reloc... " >&6; }
+if ${libc_cv_has_glob_dat+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat > conftest.c <<EOF
+extern int mumble;
+int foo (void) { return mumble; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
+ -fPIC -shared -o conftest.so conftest.c
+ -nostdlib -nostartfiles
+ 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then
+ if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
+ libc_cv_has_glob_dat=yes
+ else
+ libc_cv_has_glob_dat=no
+ fi
+else
+ libc_cv_has_glob_dat=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_has_glob_dat" >&5
+$as_echo "$libc_cv_has_glob_dat" >&6; }
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5
$as_echo_n "checking linker output format... " >&6; }
if ${libc_cv_output_format+:} false; then :
diff --git a/configure.ac b/configure.ac
index 7e9383a..8be612d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1535,6 +1535,29 @@ $ac_try"
use_default_link=$libc_cv_use_default_link
fi
+AC_CACHE_CHECK(for GLOB_DAT reloc,
+ libc_cv_has_glob_dat, [dnl
+cat > conftest.c <<EOF
+extern int mumble;
+int foo (void) { return mumble; }
+EOF
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
+ -fPIC -shared -o conftest.so conftest.c
+ -nostdlib -nostartfiles
+ 1>&AS_MESSAGE_LOG_FD])
+then
+dnl look for GLOB_DAT relocation.
+ if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
+ libc_cv_has_glob_dat=yes
+ else
+ libc_cv_has_glob_dat=no
+ fi
+else
+ libc_cv_has_glob_dat=no
+fi
+rm -f conftest*])
+AC_SUBST(libc_cv_has_glob_dat)
+
AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
if libc_cv_output_format=`
${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
diff --git a/elf/Makefile b/elf/Makefile
index 4ceeaf8..a2c43bc 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -148,7 +148,8 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
tst-nodelete) \
tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
- tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened
+ tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
+ tst-nodelete2
# reldep9
ifeq ($(build-hardcoded-path-in-tests),yes)
tests += tst-dlopen-aout
@@ -218,7 +219,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
tst-initorder2d \
tst-relsort1mod1 tst-relsort1mod2 tst-array2dep \
tst-array5dep tst-null-argv-lib \
- tst-tlsalign-lib tst-nodelete-opened-lib
+ tst-tlsalign-lib tst-nodelete-opened-lib tst-nodelete2mod
ifeq (yes,$(have-protected-data))
modules-names += tst-protected1moda tst-protected1modb
tests += tst-protected1a tst-protected1b
@@ -292,6 +293,13 @@ check-abi: $(objpfx)check-abi-ld.out
tests-special += $(objpfx)check-abi-ld.out
update-abi: update-abi-ld
+ifeq ($(have-glob-dat-reloc),yes)
+tests += tst-prelink
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)tst-prelink-cmp.out
+endif
+endif
+
include ../Rules
ifeq (yes,$(build-shared))
@@ -594,6 +602,7 @@ tst-auditmod9b.so-no-z-defs = yes
tst-nodelete-uniquemod.so-no-z-defs = yes
tst-nodelete-rtldmod.so-no-z-defs = yes
tst-nodelete-zmod.so-no-z-defs = yes
+tst-nodelete2mod.so-no-z-defs = yes
ifeq ($(build-shared),yes)
# Build all the modules even when not actually running test programs.
@@ -1164,6 +1173,11 @@ $(objpfx)tst-nodelete.out: $(objpfx)tst-nodelete-uniquemod.so \
LDFLAGS-tst-nodelete = -rdynamic
LDFLAGS-tst-nodelete-zmod.so = -Wl,--enable-new-dtags,-z,nodelete
+$(objpfx)tst-nodelete2: $(libdl)
+$(objpfx)tst-nodelete2.out: $(objpfx)tst-nodelete2mod.so
+
+LDFLAGS-tst-nodelete2 = -rdynamic
+
$(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
cmp $^ > $@; \
$(evaluate-test)
@@ -1205,3 +1219,13 @@ $(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
$(objpfx)tst-unused-dep-cmp.out: $(objpfx)tst-unused-dep.out
cmp $< /dev/null > $@; \
$(evaluate-test)
+
+tst-prelink-ENV = LD_TRACE_PRELINKING=1
+
+$(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out
+ grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@
+
+$(objpfx)tst-prelink-cmp.out: tst-prelink.exp \
+ $(objpfx)tst-prelink-conflict.out
+ cmp $^ > $@; \
+ $(evaluate-test)
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 9105277..c897247 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -144,6 +144,14 @@ _dl_close_worker (struct link_map *map, bool force)
char done[nloaded];
struct link_map *maps[nloaded];
+ /* Clear DF_1_NODELETE to force object deletion. We don't need to touch
+ l_tls_dtor_count because forced object deletion only happens when an
+ error occurs during object load. Destructor registration for TLS
+ non-POD objects should not have happened till then for this
+ object. */
+ if (force)
+ map->l_flags_1 &= ~DF_1_NODELETE;
+
/* Run over the list and assign indexes to the link maps and enter
them into the MAPS array. */
int idx = 0;
@@ -153,13 +161,6 @@ _dl_close_worker (struct link_map *map, bool force)
maps[idx] = l;
++idx;
- /* Clear DF_1_NODELETE to force object deletion. We don't need to touch
- l_tls_dtor_count because forced object deletion only happens when an
- error occurs during object load. Destructor registration for TLS
- non-POD objects should not have happened till then for this
- object. */
- if (force)
- l->l_flags_1 &= ~DF_1_NODELETE;
}
assert (idx == nloaded);
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 0c052e4..7e6f4c5 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -42,6 +42,7 @@
#include <dl-map-segments.h>
#include <dl-unmap-segments.h>
#include <dl-machine-reject-phdr.h>
+#include <dl-sysdep-open.h>
#include <endian.h>
@@ -1471,9 +1472,13 @@ print_search_path (struct r_search_path_elem **list,
ignore only ELF files for other architectures. Non-ELF files and
ELF files with different header information cause fatal errors since
this could mean there is something wrong in the installation and the
- user might want to know about this. */
+ user might want to know about this.
+
+ If FD is not -1, then the file is already open and FD refers to it.
+ In that case, FD is consumed for both successful and error returns. */
static int
-open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
+open_verify (const char *name, int fd,
+ struct filebuf *fbp, struct link_map *loader,
int whatcode, int mode, bool *found_other_class, bool free_name)
{
/* This is the expected ELF header. */
@@ -1514,6 +1519,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
if (__glibc_unlikely (GLRO(dl_naudit) > 0) && whatcode != 0
&& loader->l_auditing == 0)
{
+ const char *original_name = name;
struct audit_ifaces *afct = GLRO(dl_audit);
for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
{
@@ -1528,11 +1534,21 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
afct = afct->next;
}
+
+ if (fd != -1 && name != original_name && strcmp (name, original_name))
+ {
+ /* An audit library changed what we're supposed to open,
+ so FD no longer matches it. */
+ __close (fd);
+ fd = -1;
+ }
}
#endif
- /* Open the file. We always open files read-only. */
- int fd = __open (name, O_RDONLY | O_CLOEXEC);
+ if (fd == -1)
+ /* Open the file. We always open files read-only. */
+ fd = __open (name, O_RDONLY | O_CLOEXEC);
+
if (fd != -1)
{
ElfW(Ehdr) *ehdr;
@@ -1801,7 +1817,7 @@ open_path (const char *name, size_t namelen, int mode,
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
_dl_debug_printf (" trying file=%s\n", buf);
- fd = open_verify (buf, fbp, loader, whatcode, mode,
+ fd = open_verify (buf, -1, fbp, loader, whatcode, mode,
found_other_class, false);
if (this_dir->status[cnt] == unknown)
{
@@ -2041,6 +2057,20 @@ _dl_map_object (struct link_map *loader, const char *name,
&loader->l_runpath_dirs, &realname, &fb, loader,
LA_SER_RUNPATH, &found_other_class);
+ if (fd == -1)
+ {
+ realname = _dl_sysdep_open_object (name, namelen, &fd);
+ if (realname != NULL)
+ {
+ fd = open_verify (realname, fd,
+ &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded,
+ LA_SER_CONFIG, mode, &found_other_class,
+ false);
+ if (fd == -1)
+ free (realname);
+ }
+ }
+
#ifdef USE_LDCONFIG
if (fd == -1
&& (__glibc_likely ((mode & __RTLD_SECURE) == 0)
@@ -2086,7 +2116,7 @@ _dl_map_object (struct link_map *loader, const char *name,
if (cached != NULL)
{
- fd = open_verify (cached,
+ fd = open_verify (cached, -1,
&fb, loader ?: GL(dl_ns)[nsid]._ns_loaded,
LA_SER_CONFIG, mode, &found_other_class,
false);
@@ -2121,7 +2151,7 @@ _dl_map_object (struct link_map *loader, const char *name,
fd = -1;
else
{
- fd = open_verify (realname, &fb,
+ fd = open_verify (realname, -1, &fb,
loader ?: GL(dl_ns)[nsid]._ns_loaded, 0, mode,
&found_other_class, true);
if (__glibc_unlikely (fd == -1))
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 11cb44b..acf5280 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -1016,6 +1016,18 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
#ifdef SHARED
if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK)
{
+/* ELF_RTYPE_CLASS_XXX must match RTYPE_CLASS_XXX used by prelink with
+ LD_TRACE_PRELINKING. */
+#define RTYPE_CLASS_VALID 8
+#define RTYPE_CLASS_PLT (8|1)
+#define RTYPE_CLASS_COPY (8|2)
+#define RTYPE_CLASS_TLS (8|4)
+#if ELF_RTYPE_CLASS_PLT != 0 && ELF_RTYPE_CLASS_PLT != 1
+# error ELF_RTYPE_CLASS_PLT must be 0 or 1!
+#endif
+#if ELF_RTYPE_CLASS_COPY != 0 && ELF_RTYPE_CLASS_COPY != 2
+# error ELF_RTYPE_CLASS_COPY must be 0 or 2!
+#endif
int conflict = 0;
struct sym_val val = { NULL, NULL };
@@ -1071,12 +1083,17 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
if (value->s)
{
+ /* Keep only ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY
+ bits since since prelink only uses them. */
+ type_class &= ELF_RTYPE_CLASS_PLT | ELF_RTYPE_CLASS_COPY;
if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info)
== STT_TLS))
- type_class = 4;
+ /* Clear the RTYPE_CLASS_VALID bit in RTYPE_CLASS_TLS. */
+ type_class = RTYPE_CLASS_TLS & ~RTYPE_CLASS_VALID;
else if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info)
== STT_GNU_IFUNC))
- type_class |= 8;
+ /* Set the RTYPE_CLASS_VALID bit. */
+ type_class |= RTYPE_CLASS_VALID;
}
if (conflict
diff --git a/elf/dl-sysdep-open.h b/elf/dl-sysdep-open.h
new file mode 100644
index 0000000..a63d9f5
--- /dev/null
+++ b/elf/dl-sysdep-open.h
@@ -0,0 +1,45 @@
+/* System-specific call to open a shared object by name. Stub version.
+ Copyright (C) 2015 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DL_SYSDEP_OPEN_H
+#define _DL_SYSDEP_OPEN_H 1
+
+#include <assert.h>
+#include <stddef.h>
+
+/* NAME is a name without slashes, as it appears in a DT_NEEDED entry
+ or a dlopen call's argument or suchlike. NAMELEN is (strlen (NAME) + 1).
+
+ Find NAME in an OS-dependent fashion, and return its "real" name.
+ Optionally fill in *FD with a file descriptor open on that file (or
+ else leave its initial value of -1). The return value is a new
+ malloc'd string, which will be free'd by the caller. If NAME is
+ resolved to an actual file that can be opened, then the return
+ value should name that file (and if *FD was not set, then a normal
+ __open call on that string will be made). If *FD was set by some
+ other means than a normal open and there is no "real" name to use,
+ then __strdup (NAME) is fine (modulo error checking). */
+
+static inline char *
+_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
+{
+ assert (*fd == -1);
+ return NULL;
+}
+
+#endif /* dl-sysdep-open.h */
diff --git a/elf/rtld.c b/elf/rtld.c
index 69873c2..07e741c 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -162,7 +162,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
._dl_hwcap_mask = HWCAP_IMPORTANT,
._dl_lazy = 1,
._dl_fpu_control = _FPU_DEFAULT,
- ._dl_pointer_guard = 1,
._dl_pagesize = EXEC_PAGESIZE,
._dl_inhibit_cache = 0,
@@ -709,15 +708,12 @@ security_init (void)
#endif
/* Set up the pointer guard as well, if necessary. */
- if (GLRO(dl_pointer_guard))
- {
- uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
- stack_chk_guard);
+ uintptr_t pointer_chk_guard
+ = _dl_setup_pointer_guard (_dl_random, stack_chk_guard);
#ifdef THREAD_SET_POINTER_GUARD
- THREAD_SET_POINTER_GUARD (pointer_chk_guard);
+ THREAD_SET_POINTER_GUARD (pointer_chk_guard);
#endif
- __pointer_chk_guard_local = pointer_chk_guard;
- }
+ __pointer_chk_guard_local = pointer_chk_guard;
/* We do not need the _dl_random value anymore. The less
information we leave behind, the better, so clear the
@@ -2471,9 +2467,6 @@ process_envvars (enum mode *modep)
GLRO(dl_use_load_bias) = envline[14] == '1' ? -1 : 0;
break;
}
-
- if (memcmp (envline, "POINTER_GUARD", 13) == 0)
- GLRO(dl_pointer_guard) = envline[14] != '0';
break;
case 14:
diff --git a/elf/tst-nodelete2.c b/elf/tst-nodelete2.c
new file mode 100644
index 0000000..388e8af
--- /dev/null
+++ b/elf/tst-nodelete2.c
@@ -0,0 +1,37 @@
+#include "../dlfcn/dlfcn.h"
+#include <stdio.h>