Skip to content
Snippets Groups Projects
Commit 9b30fb27 authored by Rocky Automation's avatar Rocky Automation :tv:
Browse files

import glibc-2.28-211.el8

parent 3836dfed
No related branches found
Tags imports/r10s/grub2-2.12-13.el10
No related merge requests found
Showing
with 6679 additions and 2 deletions
......@@ -159,7 +159,8 @@ en_SG/ISO-8859-1 \
en_US.UTF-8/UTF-8 \
en_US/ISO-8859-1 \
en_US.ISO-8859-15/ISO-8859-15 \
en_US@ampm.UTF-8/UTF-8 \
en_US@ampm/UTF-8 \
en_US.UTF-8@ampm/UTF-8 \
en_ZA.UTF-8/UTF-8 \
en_ZA/ISO-8859-1 \
en_ZM/UTF-8 \
......
......@@ -448,7 +448,7 @@ fill_archive (struct locarhandle *tmpl_ah,
char fullname[fnamelen + 2 * strlen (d->d_name) + 7];
#ifdef _DIRENT_HAVE_D_TYPE
if (d_type == DT_UNKNOWN)
if (d_type == DT_UNKNOWN || d_type == DT_LNK)
#endif
{
strcpy (stpcpy (stpcpy (fullname, fname), "/"),
......
This diff is collapsed.
commit f17164bd51db31f47fbbdae826c63b6d78184c45
Author: Florian Weimer <fweimer@redhat.com>
Date: Tue May 18 07:21:33 2021 +0200
localedata: Use U+00AF MACRON in more EBCDIC charsets [BZ #27882]
This updates IBM256, IBM277, IBM278, IBM280, IBM284, IBM297, IBM424
in the same way that IBM273 was updated for bug 23290.
IBM256 and IBM424 still have holes after this change, so HAS_HOLES
is not updated.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
diff --git a/iconvdata/ibm277.c b/iconvdata/ibm277.c
index f93ca2acb8718dd5..0e337dbbdc06a02f 100644
--- a/iconvdata/ibm277.c
+++ b/iconvdata/ibm277.c
@@ -23,6 +23,6 @@
#define TABLES <ibm277.h>
#define CHARSET_NAME "IBM277//"
-#define HAS_HOLES 1 /* Not all 256 character are defined. */
+#define HAS_HOLES 0
#include <8bit-gap.c>
diff --git a/iconvdata/ibm278.c b/iconvdata/ibm278.c
index 4263000760472913..7450fb8e5b846101 100644
--- a/iconvdata/ibm278.c
+++ b/iconvdata/ibm278.c
@@ -23,6 +23,6 @@
#define TABLES <ibm278.h>
#define CHARSET_NAME "IBM278//"
-#define HAS_HOLES 1 /* Not all 256 character are defined. */
+#define HAS_HOLES 0
#include <8bit-gap.c>
diff --git a/iconvdata/ibm280.c b/iconvdata/ibm280.c
index 3efddd7dec2728d9..2ea5478e4e0d7007 100644
--- a/iconvdata/ibm280.c
+++ b/iconvdata/ibm280.c
@@ -23,6 +23,6 @@
#define TABLES <ibm280.h>
#define CHARSET_NAME "IBM280//"
-#define HAS_HOLES 1 /* Not all 256 character are defined. */
+#define HAS_HOLES 0
#include <8bit-gap.c>
diff --git a/iconvdata/ibm284.c b/iconvdata/ibm284.c
index 57dab27d0cec4a33..8dbbc6344d18528f 100644
--- a/iconvdata/ibm284.c
+++ b/iconvdata/ibm284.c
@@ -23,6 +23,6 @@
#define TABLES <ibm284.h>
#define CHARSET_NAME "IBM284//"
-#define HAS_HOLES 1 /* Not all 256 character are defined. */
+#define HAS_HOLES 0
#include <8bit-gap.c>
diff --git a/iconvdata/ibm297.c b/iconvdata/ibm297.c
index f355659afd4b4502..81e63ba1f28f1548 100644
--- a/iconvdata/ibm297.c
+++ b/iconvdata/ibm297.c
@@ -23,6 +23,6 @@
#define TABLES <ibm297.h>
#define CHARSET_NAME "IBM297//"
-#define HAS_HOLES 1 /* Not all 256 character are defined. */
+#define HAS_HOLES 0
#include <8bit-gap.c>
diff --git a/localedata/charmaps/IBM256 b/localedata/charmaps/IBM256
index 5cfd2db5f436cd07..bdc1abf0ade3bfc4 100644
--- a/localedata/charmaps/IBM256
+++ b/localedata/charmaps/IBM256
@@ -194,7 +194,7 @@ CHARMAP
<U00BE> /xb9 VULGAR FRACTION THREE QUARTERS
<U00AC> /xba NOT SIGN
<U007C> /xbb VERTICAL LINE
-<U203E> /xbc OVERLINE
+<U00AF> /xbc MACRON
<U00A8> /xbd DIAERESIS
<U00B4> /xbe ACUTE ACCENT
<U2017> /xbf DOUBLE LOW LINE
diff --git a/localedata/charmaps/IBM277 b/localedata/charmaps/IBM277
index 1c0b5cb9fb659364..2f6e3992109a2b33 100644
--- a/localedata/charmaps/IBM277
+++ b/localedata/charmaps/IBM277
@@ -195,7 +195,7 @@ CHARMAP
<U00BE> /xb9 VULGAR FRACTION THREE QUARTERS
<U00AC> /xba NOT SIGN
<U007C> /xbb VERTICAL LINE
-<U203E> /xbc OVERLINE
+<U00AF> /xbc MACRON
<U00A8> /xbd DIAERESIS
<U00B4> /xbe ACUTE ACCENT
<U00D7> /xbf MULTIPLICATION SIGN
diff --git a/localedata/charmaps/IBM278 b/localedata/charmaps/IBM278
index 646961501c74c4df..bdfae7621028f003 100644
--- a/localedata/charmaps/IBM278
+++ b/localedata/charmaps/IBM278
@@ -196,7 +196,7 @@ CHARMAP
<U00BE> /xb9 VULGAR FRACTION THREE QUARTERS
<U00AC> /xba NOT SIGN
<U007C> /xbb VERTICAL LINE
-<U203E> /xbc OVERLINE
+<U00AF> /xbc MACRON
<U00A8> /xbd DIAERESIS
<U00B4> /xbe ACUTE ACCENT
<U00D7> /xbf MULTIPLICATION SIGN
diff --git a/localedata/charmaps/IBM280 b/localedata/charmaps/IBM280
index 5de3b3e7b96796c0..4c31242806b0ac19 100644
--- a/localedata/charmaps/IBM280
+++ b/localedata/charmaps/IBM280
@@ -195,7 +195,7 @@ CHARMAP
<U00BE> /xb9 VULGAR FRACTION THREE QUARTERS
<U00AC> /xba NOT SIGN
<U007C> /xbb VERTICAL LINE
-<U203E> /xbc OVERLINE
+<U00AF> /xbc MACRON
<U00A8> /xbd DIAERESIS
<U00B4> /xbe ACUTE ACCENT
<U00D7> /xbf MULTIPLICATION SIGN
diff --git a/localedata/charmaps/IBM284 b/localedata/charmaps/IBM284
index c64b2a65ab748540..46a8737a715e4e56 100644
--- a/localedata/charmaps/IBM284
+++ b/localedata/charmaps/IBM284
@@ -195,7 +195,7 @@ CHARMAP
<U00BE> /xb9 VULGAR FRACTION THREE QUARTERS
<U005E> /xba CIRCUMFLEX ACCENT
<U0021> /xbb EXCLAMATION MARK
-<U203E> /xbc OVERLINE
+<U00AF> /xbc MACRON
<U007E> /xbd TILDE
<U00B4> /xbe ACUTE ACCENT
<U00D7> /xbf MULTIPLICATION SIGN
diff --git a/localedata/charmaps/IBM297 b/localedata/charmaps/IBM297
index 33b74eee437241aa..14361ad418cf1bc7 100644
--- a/localedata/charmaps/IBM297
+++ b/localedata/charmaps/IBM297
@@ -195,7 +195,7 @@ CHARMAP
<U00BE> /xb9 VULGAR FRACTION THREE QUARTERS
<U00AC> /xba NOT SIGN
<U007C> /xbb VERTICAL LINE
-<U203E> /xbc OVERLINE
+<U00AF> /xbc MACRON
<U007E> /xbd TILDE
<U00B4> /xbe ACUTE ACCENT
<U00D7> /xbf MULTIPLICATION SIGN
diff --git a/localedata/charmaps/IBM424 b/localedata/charmaps/IBM424
index 883e43b8ae04ee4c..deca11e1b18ec0a6 100644
--- a/localedata/charmaps/IBM424
+++ b/localedata/charmaps/IBM424
@@ -175,7 +175,7 @@ CHARMAP
<U00BE> /xb9 VULGAR FRACTION THREE QUARTERS
<U005B> /xba LEFT SQUARE BRACKET
<U005D> /xbb RIGHT SQUARE BRACKET
-<U203E> /xbc OVERLINE
+<U00AF> /xbc MACRON
<U00A8> /xbd DIAERESIS
<U00B4> /xbe ACUTE ACCENT
<U00D7> /xbf MULTIPLICATION SIGN
This diff is collapsed.
commit 2a08b6e8331a611dc29325bfa6e29fecc9a3a46e
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Thu Dec 10 16:47:02 2020 +0530
Warn on unsupported fortification levels
Make the _FORTIFY_SOURCE macro soup in features.h warn about
unsupported fortification levels. For example, it will warn about
_FORTIFY_SOURCE=3 and over with an indication of which level has been
selected.
Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
diff --git a/include/features.h b/include/features.h
index 5bed0a499605a3a2..ea7673ee115bcf0a 100644
--- a/include/features.h
+++ b/include/features.h
@@ -382,6 +382,9 @@
# elif !__GNUC_PREREQ (4, 1)
# warning _FORTIFY_SOURCE requires GCC 4.1 or later
# elif _FORTIFY_SOURCE > 1
+# if _FORTIFY_SOURCE > 2
+# warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform
+# endif
# define __USE_FORTIFY_LEVEL 2
# else
# define __USE_FORTIFY_LEVEL 1
commit 2bbd07c715275eb6c616988925738a0517180d57
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Fri Dec 17 18:35:44 2021 +0530
fortify: Fix spurious warning with realpath
The length and object size arguments were swapped around for realpath.
Also add a smoke test so that any changes in this area get caught in
future.
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
diff --git a/debug/Makefile b/debug/Makefile
index 81361438fc3d2aa9..b43f42ee3851f360 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -108,6 +108,7 @@ CFLAGS-tst-longjmp_chk2.c += -fexceptions -fasynchronous-unwind-tables
CPPFLAGS-tst-longjmp_chk2.c += -D_FORTIFY_SOURCE=1
CFLAGS-tst-longjmp_chk3.c += -fexceptions -fasynchronous-unwind-tables
CPPFLAGS-tst-longjmp_chk3.c += -D_FORTIFY_SOURCE=1
+CPPFLAGS-tst-realpath-chk.c += -D_FORTIFY_SOURCE=2
# We know these tests have problems with format strings, this is what
# we are testing. Disable that warning. They are also testing
@@ -155,7 +156,7 @@ tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
tst-chk4 tst-chk5 tst-chk6 tst-chk7 tst-chk8 tst-lfschk4 tst-lfschk5 \
tst-lfschk6 tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 \
- tst-backtrace4 tst-backtrace5 tst-backtrace6
+ tst-backtrace4 tst-backtrace5 tst-backtrace6 tst-realpath-chk
ifeq ($(have-ssp),yes)
tests += tst-ssp-1
diff --git a/debug/tst-realpath-chk.c b/debug/tst-realpath-chk.c
new file mode 100644
index 0000000000000000..a8fcb327c43fb34d
--- /dev/null
+++ b/debug/tst-realpath-chk.c
@@ -0,0 +1,37 @@
+/* Smoke test to verify that realpath does not cause spurious warnings.
+ Copyright The GNU Toolchain Authors.
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <limits.h>
+#include <stdlib.h>
+
+#include <support/check.h>
+#include <support/support.h>
+
+static int
+do_test (void)
+{
+#ifdef PATH_MAX
+ char buf[PATH_MAX + 1];
+ char *res = realpath (".", buf);
+ TEST_VERIFY (res == buf);
+#endif
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
index 7ea364a276497720..81ec9bdb32215e3b 100644
--- a/stdlib/bits/stdlib.h
+++ b/stdlib/bits/stdlib.h
@@ -42,7 +42,7 @@ __NTH (realpath (const char *__restrict __name, char *__restrict __resolved))
return __realpath_alias (__name, __resolved);
#if defined _LIBC_LIMITS_H_ && defined PATH_MAX
- if (__glibc_unsafe_len (sz, sizeof (char), PATH_MAX))
+ if (__glibc_unsafe_len (PATH_MAX, sizeof (char), sz))
return __realpath_chk_warn (__name, __resolved, sz);
#endif
return __realpath_chk (__name, __resolved, sz);
commit 86bf0feb0e3ec8e37872f72499d6ae33406561d7
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Wed Jan 12 18:46:28 2022 +0530
Enable _FORTIFY_SOURCE=3 for gcc 12 and above
gcc 12 now has support for the __builtin_dynamic_object_size builtin.
Adapt the macro checks to enable _FORTIFY_SOURCE=3 on gcc 12 and above.
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
diff --git a/include/features.h b/include/features.h
index fe9fe16d034fad1b..2e9ca6ec2f4a0380 100644
--- a/include/features.h
+++ b/include/features.h
@@ -381,7 +381,9 @@
# warning _FORTIFY_SOURCE requires compiling with optimization (-O)
# elif !__GNUC_PREREQ (4, 1)
# warning _FORTIFY_SOURCE requires GCC 4.1 or later
-# elif _FORTIFY_SOURCE > 2 && __glibc_clang_prereq (9, 0)
+# elif _FORTIFY_SOURCE > 2 && (__glibc_clang_prereq (9, 0) \
+ || __GNUC_PREREQ (12, 0))
+
# if _FORTIFY_SOURCE > 3
# warning _FORTIFY_SOURCE > 3 is treated like 3 on this platform
# endif
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 147339957c4ad490..a17ae0ed87e6163f 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -124,7 +124,8 @@
#define __bos0(ptr) __builtin_object_size (ptr, 0)
/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
-#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
+#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
+ || __GNUC_PREREQ (12, 0))
# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
#else
commit db27f1251b008280a29d540b4f8ab2a38a0d80af
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Wed Jan 12 23:34:23 2022 +0530
debug: Autogenerate _FORTIFY_SOURCE tests
Rename debug/tst-chk1.c to debug/tst-fortify.c and add make hackery to
autogenerate tests with different macros enabled to build and run the
same test with different configurations as well as different
fortification levels.
The change also ends up expanding the -lfs tests to include
_FORTIFY_SOURCE=3.
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
# Conflicts:
# debug/Makefile
diff --git a/Makerules b/Makerules
index 5d6434c74bf9bfe5..05a549eb0f259113 100644
--- a/Makerules
+++ b/Makerules
@@ -444,6 +444,12 @@ $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
endef
object-suffixes-left := $(all-object-suffixes)
include $(o-iterator)
+
+define o-iterator-doit
+$(objpfx)%$o: $(objpfx)%.cc $(before-compile); $$(compile-command.cc)
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
endif
# Generate version maps, but wait until sysdep-subdirs is known
diff --git a/debug/Makefile b/debug/Makefile
index b43f42ee3851f360..c92fd23dda1a7279 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -1,4 +1,5 @@
-# Copyright (C) 1998-2018 Free Software Foundation, Inc.
+# Copyright (C) 1998-2022 Free Software Foundation, Inc.
+# Copyright The GNU Toolchain Authors.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -110,32 +111,60 @@ CFLAGS-tst-longjmp_chk3.c += -fexceptions -fasynchronous-unwind-tables
CPPFLAGS-tst-longjmp_chk3.c += -D_FORTIFY_SOURCE=1
CPPFLAGS-tst-realpath-chk.c += -D_FORTIFY_SOURCE=2
+# _FORTIFY_SOURCE tests.
+# Auto-generate tests for _FORTIFY_SOURCE for different levels, compilers and
+# preprocessor conditions based on tst-fortify.c.
+#
+# To add a new test condition, define a cflags-$(cond) make variable to set
+# CFLAGS for the file.
+
+tests-all-chk = tst-fortify
+tests-c-chk =
+tests-cc-chk =
+
+CFLAGS-tst-fortify.c += -Wno-format -Wno-deprecated-declarations -Wno-error
+
+# No additional flags for the default tests.
+define cflags-default
+endef
+
+define cflags-lfs
+CFLAGS-tst-fortify-$(1)-lfs-$(2).$(1) += -D_FILE_OFFSET_BITS=64
+endef
+
# We know these tests have problems with format strings, this is what
# we are testing. Disable that warning. They are also testing
# deprecated functions (notably gets) so disable that warning as well.
# And they also generate warnings from warning attributes, which
# cannot be disabled via pragmas, so require -Wno-error to be used.
-CFLAGS-tst-chk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-chk2.c += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-chk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-chk4.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-chk5.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-chk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-chk7.c += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-chk8.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-lfschk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-lfschk2.c += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-lfschk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-lfschk4.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-lfschk5.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
-CFLAGS-tst-lfschk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
-LDLIBS-tst-chk4 = -lstdc++
-LDLIBS-tst-chk5 = -lstdc++
-LDLIBS-tst-chk6 = -lstdc++
-LDLIBS-tst-chk8 = -lstdc++
-LDLIBS-tst-lfschk4 = -lstdc++
-LDLIBS-tst-lfschk5 = -lstdc++
-LDLIBS-tst-lfschk6 = -lstdc++
+define gen-chk-test
+tests-$(1)-chk += tst-fortify-$(1)-$(2)-$(3)
+CFLAGS-tst-fortify-$(1)-$(2)-$(3).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \
+ -Wno-deprecated-declarations \
+ -Wno-error
+$(eval $(call cflags-$(2),$(1),$(3)))
+$(objpfx)tst-fortify-$(1)-$(2)-$(3).$(1): tst-fortify.c Makefile
+ ( echo "/* Autogenerated from Makefile. */"; \
+ echo ""; \
+ echo "#include \"tst-fortify.c\"" ) > $$@.tmp
+ mv $$@.tmp $$@
+endef
+
+chk-extensions = c cc
+chk-types = default lfs
+chk-levels = 1 2 3
+
+$(foreach e,$(chk-extensions), \
+ $(foreach t,$(chk-types), \
+ $(foreach l,$(chk-levels), \
+ $(eval $(call gen-chk-test,$(e),$(t),$(l))))))
+
+tests-all-chk += $(tests-c-chk) $(tests-cc-chk)
+
+define link-cc
+LDLIBS-$(1) = -lstdc++
+endef
+$(foreach t,$(tests-cc-chk), $(eval $(call link-cc,$(t))))
# backtrace_symbols only works if we link with -rdynamic. backtrace
# requires unwind tables on most architectures.
@@ -152,19 +181,25 @@ LDFLAGS-tst-backtrace6 = -rdynamic
CFLAGS-tst-ssp-1.c += -fstack-protector-all
-tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
- tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
- tst-chk4 tst-chk5 tst-chk6 tst-chk7 tst-chk8 tst-lfschk4 tst-lfschk5 \
- tst-lfschk6 tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 \
- tst-backtrace4 tst-backtrace5 tst-backtrace6 tst-realpath-chk
+tests = backtrace-tst \
+ tst-longjmp_chk \
+ test-strcpy_chk \
+ test-stpcpy_chk \
+ tst-longjmp_chk2 \
+ tst-backtrace2 \
+ tst-backtrace3 \
+ tst-backtrace4 \
+ tst-backtrace5 \
+ tst-backtrace6 \
+ tst-realpath-chk \
+ $(tests-all-chk)
ifeq ($(have-ssp),yes)
tests += tst-ssp-1
endif
ifeq (,$(CXX))
-tests-unsupported = tst-chk4 tst-chk5 tst-chk6 tst-chk8 \
- tst-lfschk4 tst-lfschk5 tst-lfschk6
+tests-unsupported = $(tests-cc-chk)
endif
extra-libs = libSegFault libpcprofile
@@ -191,20 +226,10 @@ ifeq ($(run-built-tests),yes)
LOCALES := de_DE.UTF-8
include ../gen-locales.mk
-$(objpfx)tst-chk1.out: $(gen-locales)
-$(objpfx)tst-chk2.out: $(gen-locales)
-$(objpfx)tst-chk3.out: $(gen-locales)
-$(objpfx)tst-chk4.out: $(gen-locales)
-$(objpfx)tst-chk5.out: $(gen-locales)
-$(objpfx)tst-chk6.out: $(gen-locales)
-$(objpfx)tst-chk7.out: $(gen-locales)
-$(objpfx)tst-chk8.out: $(gen-locales)
-$(objpfx)tst-lfschk1.out: $(gen-locales)
-$(objpfx)tst-lfschk2.out: $(gen-locales)
-$(objpfx)tst-lfschk3.out: $(gen-locales)
-$(objpfx)tst-lfschk4.out: $(gen-locales)
-$(objpfx)tst-lfschk5.out: $(gen-locales)
-$(objpfx)tst-lfschk6.out: $(gen-locales)
+define chk-gen-locales
+$(objpfx)$(1).out: $(gen-locales)
+endef
+$(foreach t, $(tests-all-chk), $(eval $(call chk-gen-locales,$(t))))
endif
sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
diff --git a/debug/tst-chk2.c b/debug/tst-chk2.c
deleted file mode 100644
index be37ce2d22f0760a..0000000000000000
--- a/debug/tst-chk2.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FORTIFY_SOURCE 1
-#include "tst-chk1.c"
diff --git a/debug/tst-chk3.c b/debug/tst-chk3.c
deleted file mode 100644
index 38b8e4fb360ba722..0000000000000000
--- a/debug/tst-chk3.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FORTIFY_SOURCE 2
-#include "tst-chk1.c"
diff --git a/debug/tst-chk4.cc b/debug/tst-chk4.cc
deleted file mode 100644
index c82e6aac86038791..0000000000000000
--- a/debug/tst-chk4.cc
+++ /dev/null
@@ -1 +0,0 @@
-#include "tst-chk1.c"
diff --git a/debug/tst-chk5.cc b/debug/tst-chk5.cc
deleted file mode 100644
index be37ce2d22f0760a..0000000000000000
--- a/debug/tst-chk5.cc
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FORTIFY_SOURCE 1
-#include "tst-chk1.c"
diff --git a/debug/tst-chk6.cc b/debug/tst-chk6.cc
deleted file mode 100644
index 38b8e4fb360ba722..0000000000000000
--- a/debug/tst-chk6.cc
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FORTIFY_SOURCE 2
-#include "tst-chk1.c"
diff --git a/debug/tst-chk7.c b/debug/tst-chk7.c
deleted file mode 100644
index 2a7b32381268135c..0000000000000000
--- a/debug/tst-chk7.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FORTIFY_SOURCE 3
-#include "tst-chk1.c"
diff --git a/debug/tst-chk8.cc b/debug/tst-chk8.cc
deleted file mode 100644
index 2a7b32381268135c..0000000000000000
--- a/debug/tst-chk8.cc
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FORTIFY_SOURCE 3
-#include "tst-chk1.c"
diff --git a/debug/tst-chk1.c b/debug/tst-fortify.c
similarity index 100%
rename from debug/tst-chk1.c
rename to debug/tst-fortify.c
diff --git a/debug/tst-lfschk1.c b/debug/tst-lfschk1.c
deleted file mode 100644
index f3e6d47d5e4484c3..0000000000000000
--- a/debug/tst-lfschk1.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FILE_OFFSET_BITS 64
-#include "tst-chk1.c"
diff --git a/debug/tst-lfschk2.c b/debug/tst-lfschk2.c
deleted file mode 100644
index 95d4db1d32d2eeb3..0000000000000000
--- a/debug/tst-lfschk2.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FILE_OFFSET_BITS 64
-#include "tst-chk2.c"
diff --git a/debug/tst-lfschk3.c b/debug/tst-lfschk3.c
deleted file mode 100644
index 50a1ae1258f1553d..0000000000000000
--- a/debug/tst-lfschk3.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FILE_OFFSET_BITS 64
-#include "tst-chk3.c"
diff --git a/debug/tst-lfschk4.cc b/debug/tst-lfschk4.cc
deleted file mode 100644
index f3e6d47d5e4484c3..0000000000000000
--- a/debug/tst-lfschk4.cc
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FILE_OFFSET_BITS 64
-#include "tst-chk1.c"
diff --git a/debug/tst-lfschk5.cc b/debug/tst-lfschk5.cc
deleted file mode 100644
index 95d4db1d32d2eeb3..0000000000000000
--- a/debug/tst-lfschk5.cc
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FILE_OFFSET_BITS 64
-#include "tst-chk2.c"
diff --git a/debug/tst-lfschk6.cc b/debug/tst-lfschk6.cc
deleted file mode 100644
index 50a1ae1258f1553d..0000000000000000
--- a/debug/tst-lfschk6.cc
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _FILE_OFFSET_BITS 64
-#include "tst-chk3.c"
commit c43c5796121bc5bcc0867f02e5536874aa8196c1
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Wed Dec 30 11:54:00 2020 +0530
Introduce _FORTIFY_SOURCE=3
Introduce a new _FORTIFY_SOURCE level of 3 to enable additional
fortifications that may have a noticeable performance impact, allowing
more fortification coverage at the cost of some performance.
With llvm 9.0 or later, this will replace the use of
__builtin_object_size with __builtin_dynamic_object_size.
__builtin_dynamic_object_size
-----------------------------
__builtin_dynamic_object_size is an LLVM builtin that is similar to
__builtin_object_size. In addition to what __builtin_object_size
does, i.e. replace the builtin call with a constant object size,
__builtin_dynamic_object_size will replace the call site with an
expression that evaluates to the object size, thus expanding its
applicability. In practice, __builtin_dynamic_object_size evaluates
these expressions through malloc/calloc calls that it can associate
with the object being evaluated.
A simple motivating example is below; -D_FORTIFY_SOURCE=2 would miss
this and emit memcpy, but -D_FORTIFY_SOURCE=3 with the help of
__builtin_dynamic_object_size is able to emit __memcpy_chk with the
allocation size expression passed into the function:
void *copy_obj (const void *src, size_t alloc, size_t copysize)
{
void *obj = malloc (alloc);
memcpy (obj, src, copysize);
return obj;
}
Limitations
-----------
If the object was allocated elsewhere that the compiler cannot see, or
if it was allocated in the function with a function that the compiler
does not recognize as an allocator then __builtin_dynamic_object_size
also returns -1.
Further, the expression used to compute object size may be non-trivial
and may potentially incur a noticeable performance impact. These
fortifications are hence enabled at a new _FORTIFY_SOURCE level to
allow developers to make a choice on the tradeoff according to their
environment.
diff --git a/include/features.h b/include/features.h
index ea7673ee115bcf0a..fe9fe16d034fad1b 100644
--- a/include/features.h
+++ b/include/features.h
@@ -381,6 +381,11 @@
# warning _FORTIFY_SOURCE requires compiling with optimization (-O)
# elif !__GNUC_PREREQ (4, 1)
# warning _FORTIFY_SOURCE requires GCC 4.1 or later
+# elif _FORTIFY_SOURCE > 2 && __glibc_clang_prereq (9, 0)
+# if _FORTIFY_SOURCE > 3
+# warning _FORTIFY_SOURCE > 3 is treated like 3 on this platform
+# endif
+# define __USE_FORTIFY_LEVEL 3
# elif _FORTIFY_SOURCE > 1
# if _FORTIFY_SOURCE > 2
# warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform
diff --git a/manual/creature.texi b/manual/creature.texi
index 8876b2ab779c988f..64f361f27a7d6cdf 100644
--- a/manual/creature.texi
+++ b/manual/creature.texi
@@ -247,7 +247,8 @@ included.
@standards{GNU, (none)}
If this macro is defined to @math{1}, security hardening is added to
various library functions. If defined to @math{2}, even stricter
-checks are applied.
+checks are applied. If defined to @math{3}, @theglibc{} may also use
+checks that may have an additional performance overhead.
@end defvr
@defvr Macro _REENTRANT
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 3f6fe3cc8563b493..1e39307b0ebcf38f 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -123,6 +123,15 @@
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
+/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
+#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
+# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
+# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
+#else
+# define __glibc_objsize0(__o) __bos0 (__o)
+# define __glibc_objsize(__o) __bos (__o)
+#endif
+
#if __GNUC_PREREQ (4,3)
# define __warndecl(name, msg) \
extern void name (void) __attribute__((__warning__ (msg)))
commit 7163ace3318d666d40771f5c8e7c4a148827070f
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Thu Nov 12 12:09:56 2020 +0530
Use __builtin___stpncpy_chk when available
The builtin has been available in gcc since 4.7.0 and in clang since
2.6. This fixes stpncpy fortification with clang since it does a
better job of plugging in __stpncpy_chk in the right place than the
header hackery.
This has been tested by building and running all tests with gcc 10.2.1
and also with clang tip as of a few days ago (just the tests in debug/
since running all tests don't work with clang at the moment) to make
sure that both compilers pass the stpncpy tests.
diff --git a/string/bits/string_fortified.h b/string/bits/string_fortified.h
index a07ab0dbc8c8dd5b..4ed6755a6c1ca247 100644
--- a/string/bits/string_fortified.h
+++ b/string/bits/string_fortified.h
@@ -106,7 +106,13 @@ __NTH (strncpy (char *__restrict __dest, const char *__restrict __src,
return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
}
-/* XXX We have no corresponding builtin yet. */
+#if __GNUC_PREREQ (4, 7) || __glibc_clang_prereq (2, 6)
+__fortify_function char *
+__NTH (stpncpy (char *__dest, const char *__src, size_t __n))
+{
+ return __builtin___stpncpy_chk (__dest, __src, __n, __bos (__dest));
+}
+#else
extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
size_t __destlen) __THROW;
extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src,
@@ -120,6 +126,7 @@ __NTH (stpncpy (char *__dest, const char *__src, size_t __n))
return __stpncpy_chk (__dest, __src, __n, __bos (__dest));
return __stpncpy_alias (__dest, __src, __n);
}
+#endif
__fortify_function char *
commit 2a3224c53653214cbba2ec23424702193c80ea3b
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Wed Dec 30 11:09:58 2020 +0530
string: Enable __FORTIFY_LEVEL=3
This change enhances fortified string functions to use
__builtin_dynamic_object_size under _FORTIFY_SOURCE=3 whenever the
compiler supports it.
# Conflicts:
# string/bits/string_fortified.h
Conflict resolved to retain __GNUC_PREREQ (5,0) macro check in RHEL-8
glibc.
diff --git a/include/string.h b/include/string.h
index 4d622f1c0305e78e..bbc97082661caf42 100644
--- a/include/string.h
+++ b/include/string.h
@@ -119,10 +119,11 @@ libc_hidden_proto (__ffs)
void __explicit_bzero_chk_internal (void *, size_t, size_t)
__THROW __nonnull ((1)) attribute_hidden;
# define explicit_bzero(buf, len) \
- __explicit_bzero_chk_internal (buf, len, __bos0 (buf))
+ __explicit_bzero_chk_internal (buf, len, __glibc_objsize0 (buf))
#elif !IS_IN (nonlib)
void __explicit_bzero_chk (void *, size_t, size_t) __THROW __nonnull ((1));
-# define explicit_bzero(buf, len) __explicit_bzero_chk (buf, len, __bos0 (buf))
+# define explicit_bzero(buf, len) __explicit_bzero_chk (buf, len, \
+ __glibc_objsize0 (buf))
#endif
libc_hidden_builtin_proto (memchr)
diff --git a/string/bits/string_fortified.h b/string/bits/string_fortified.h
index 4ed6755a6c1ca247..27ec273ec41cd81c 100644
--- a/string/bits/string_fortified.h
+++ b/string/bits/string_fortified.h
@@ -31,13 +31,15 @@ __fortify_function void *
__NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
size_t __len))
{
- return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
+ return __builtin___memcpy_chk (__dest, __src, __len,
+ __glibc_objsize0 (__dest));
}
__fortify_function void *
__NTH (memmove (void *__dest, const void *__src, size_t __len))
{
- return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest));
+ return __builtin___memmove_chk (__dest, __src, __len,
+ __glibc_objsize0 (__dest));
}
#ifdef __USE_GNU
@@ -45,7 +47,8 @@ __fortify_function void *
__NTH (mempcpy (void *__restrict __dest, const void *__restrict __src,
size_t __len))
{
- return __builtin___mempcpy_chk (__dest, __src, __len, __bos0 (__dest));
+ return __builtin___mempcpy_chk (__dest, __src, __len,
+ __glibc_objsize0 (__dest));
}
#endif
@@ -68,7 +71,8 @@ __NTH (memset (void *__dest, int __ch, size_t __len))
return __dest;
}
#endif
- return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
+ return __builtin___memset_chk (__dest, __ch, __len,
+ __glibc_objsize0 (__dest));
}
#ifdef __USE_MISC
@@ -80,21 +84,21 @@ void __explicit_bzero_chk (void *__dest, size_t __len, size_t __destlen)
__fortify_function void
__NTH (explicit_bzero (void *__dest, size_t __len))
{
- __explicit_bzero_chk (__dest, __len, __bos0 (__dest));
+ __explicit_bzero_chk (__dest, __len, __glibc_objsize0 (__dest));
}
#endif
__fortify_function char *
__NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
{
- return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
+ return __builtin___strcpy_chk (__dest, __src, __glibc_objsize (__dest));
}
#ifdef __USE_GNU
__fortify_function char *
__NTH (stpcpy (char *__restrict __dest, const char *__restrict __src))
{
- return __builtin___stpcpy_chk (__dest, __src, __bos (__dest));
+ return __builtin___stpcpy_chk (__dest, __src, __glibc_objsize (__dest));
}
#endif
@@ -103,14 +107,16 @@ __fortify_function char *
__NTH (strncpy (char *__restrict __dest, const char *__restrict __src,
size_t __len))
{
- return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
+ return __builtin___strncpy_chk (__dest, __src, __len,
+ __glibc_objsize (__dest));
}
#if __GNUC_PREREQ (4, 7) || __glibc_clang_prereq (2, 6)
__fortify_function char *
__NTH (stpncpy (char *__dest, const char *__src, size_t __n))
{
- return __builtin___stpncpy_chk (__dest, __src, __n, __bos (__dest));
+ return __builtin___stpncpy_chk (__dest, __src, __n,
+ __glibc_objsize (__dest));
}
#else
extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
@@ -132,7 +138,7 @@ __NTH (stpncpy (char *__dest, const char *__src, size_t __n))
__fortify_function char *
__NTH (strcat (char *__restrict __dest, const char *__restrict __src))
{
- return __builtin___strcat_chk (__dest, __src, __bos (__dest));
+ return __builtin___strcat_chk (__dest, __src, __glibc_objsize (__dest));
}
@@ -140,7 +146,8 @@ __fortify_function char *
__NTH (strncat (char *__restrict __dest, const char *__restrict __src,
size_t __len))
{
- return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
+ return __builtin___strncat_chk (__dest, __src, __len,
+ __glibc_objsize (__dest));
}
#endif /* bits/string_fortified.h */
diff --git a/string/bits/strings_fortified.h b/string/bits/strings_fortified.h
index d9b2804525cfa994..871515bd2cba1f8a 100644
--- a/string/bits/strings_fortified.h
+++ b/string/bits/strings_fortified.h
@@ -22,13 +22,15 @@
__fortify_function void
__NTH (bcopy (const void *__src, void *__dest, size_t __len))
{
- (void) __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest));
+ (void) __builtin___memmove_chk (__dest, __src, __len,
+ __glibc_objsize0 (__dest));
}
__fortify_function void
__NTH (bzero (void *__dest, size_t __len))
{
- (void) __builtin___memset_chk (__dest, '\0', __len, __bos0 (__dest));
+ (void) __builtin___memset_chk (__dest, '\0', __len,
+ __glibc_objsize0 (__dest));
}
#endif
This diff is collapsed.
This diff is collapsed.
commit fadf75c370494da6a02274ebe79e45b2f22ebbd0
Author: Florian Weimer <fweimer@redhat.com>
Date: Mon Feb 10 14:37:10 2020 +0100
debug: Add missing locale dependencies of fortify tests
The missing dependencies result in failures like this if make check
is invoked with sufficient parallelism for the debug subdirectory:
FAIL: debug/tst-chk2
FAIL: debug/tst-chk3
FAIL: debug/tst-chk4
FAIL: debug/tst-chk5
FAIL: debug/tst-chk6
FAIL: debug/tst-lfschk1
FAIL: debug/tst-lfschk2
FAIL: debug/tst-lfschk3
FAIL: debug/tst-lfschk4
FAIL: debug/tst-lfschk5
FAIL: debug/tst-lfschk6
diff --git a/debug/Makefile b/debug/Makefile
index 506cebc3c4ca19ff..5e45c9b41077f2fd 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -188,6 +188,17 @@ LOCALES := de_DE.UTF-8
include ../gen-locales.mk
$(objpfx)tst-chk1.out: $(gen-locales)
+$(objpfx)tst-chk2.out: $(gen-locales)
+$(objpfx)tst-chk3.out: $(gen-locales)
+$(objpfx)tst-chk4.out: $(gen-locales)
+$(objpfx)tst-chk5.out: $(gen-locales)
+$(objpfx)tst-chk6.out: $(gen-locales)
+$(objpfx)tst-lfschk1.out: $(gen-locales)
+$(objpfx)tst-lfschk2.out: $(gen-locales)
+$(objpfx)tst-lfschk3.out: $(gen-locales)
+$(objpfx)tst-lfschk4.out: $(gen-locales)
+$(objpfx)tst-lfschk5.out: $(gen-locales)
+$(objpfx)tst-lfschk6.out: $(gen-locales)
endif
sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
This diff is collapsed.
commit ae23fa3e5fe24daf94fc7f8e5268bb8ceeda7477
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Thu Dec 16 07:19:14 2021 +0530
__glibc_unsafe_len: Fix comment
We know that the length is *unsafe*.
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 17b84a2e6c69d961..147339957c4ad490 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -150,7 +150,7 @@
__s, __osz)) \
&& __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
-/* Conversely, we know at compile time that the length is safe if the
+/* Conversely, we know at compile time that the length is unsafe if the
__L * __S <= __OBJSZ condition can be folded to a constant and if it is
false. */
#define __glibc_unsafe_len(__l, __s, __osz) \
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment