Linux cpanel.rrshost.in 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64
Apache
: 109.123.238.221 | : 108.162.216.54
128 Domain
8.2.28
aev999
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
src /
glibc /
debian /
patches /
[ HOME SHELL ]
Name
Size
Permission
Action
all
[ DIR ]
drwxr-xr-x
alpha
[ DIR ]
drwxr-xr-x
any
[ DIR ]
drwxr-xr-x
arm
[ DIR ]
drwxr-xr-x
hppa
[ DIR ]
drwxr-xr-x
hurd-i386
[ DIR ]
drwxr-xr-x
i386
[ DIR ]
drwxr-xr-x
kfreebsd
[ DIR ]
drwxr-xr-x
locale
[ DIR ]
drwxr-xr-x
localedata
[ DIR ]
drwxr-xr-x
lp2011421
[ DIR ]
drwxr-xr-x
lp2047155
[ DIR ]
drwxr-xr-x
m68k
[ DIR ]
drwxr-xr-x
mips
[ DIR ]
drwxr-xr-x
powerpc
[ DIR ]
drwxr-xr-x
riscv64
[ DIR ]
drwxr-xr-x
sh4
[ DIR ]
drwxr-xr-x
ubuntu
[ DIR ]
drwxr-xr-x
upstream-updates
[ DIR ]
drwxr-xr-x
CVE-2024-33599.patch
1.11
KB
-rw-r--r--
CVE-2024-33600_1.patch
2.22
KB
-rw-r--r--
CVE-2024-33600_2.patch
1.78
KB
-rw-r--r--
CVE-2024-33601_33602.patch
12.16
KB
-rw-r--r--
README
881
B
-rw-r--r--
git-updates.diff
49.71
KB
-rw-r--r--
lp1992159-socket-Fix-mistyped-...
1022
B
-rw-r--r--
lp1995362-elf-Fix-DFS-sorting-...
12.43
KB
-rw-r--r--
lp2007599-S390-Influence-hwcap...
22.51
KB
-rw-r--r--
lp2007796-debug-make-__read_ch...
4.21
KB
-rw-r--r--
series
6.66
KB
-rw-r--r--
series.hurd-i386
428
B
-rw-r--r--
series.kfreebsd-amd64
200
B
-rw-r--r--
series.kfreebsd-i386
200
B
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : git-updates.diff
GIT update of https://sourceware.org/git/glibc.git/release/2.35/master from glibc-2.35 to e30c1c73da3f220f5bf0063a1d0344f8280311e7 diff --git a/NEWS b/NEWS index faa7ec1871..d11e2d9d31 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,23 @@ See the end for copying conditions. Please send GNU C library bug reports via <https://sourceware.org/bugzilla/> using `glibc' in the "product" field. + +Version 2.35.1 + +The following bugs are resolved with this release: + + [28838] FAIL: elf/tst-p_align3 + [28850] linux: __get_nprocs_sched reads uninitialized memory from the stack + [28853] libc: tst-spawn6 changes current foreground process group + (breaks test isolation) + [28857] libc: FAIL: elf/tst-audit24a + [28860] build: --enable-kernel=5.1.0 build fails because of missing + __convert_scm_timestamps + [28865] linux: _SC_NPROCESSORS_CONF and _SC_NPROCESSORS_ONLN are inaccurate + without /sys and /proc + [28896] strncmp-avx2-rtm and wcsncmp-avx2-rtm fallback on non-rtm + variants when avoiding overflow + Version 2.35 diff --git a/configure b/configure index 00dc638388..8e5bee775a 100755 --- a/configure +++ b/configure @@ -730,7 +730,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -845,7 +844,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1098,15 +1096,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1244,7 +1233,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1397,7 +1386,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] diff --git a/elf/Makefile b/elf/Makefile index 5bdf0a383d..b2bd03a9f6 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -943,7 +943,7 @@ extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special # rules. modules-names-nobuild := filtmod1 tst-big-note-lib tst-ro-dynamic-mod \ - tst-audit24bmod1 tst-audit24bmod2.so + tst-audit24bmod1 tst-audit24bmod2 tests += $(tests-static) @@ -2210,7 +2210,7 @@ $(objpfx)tst-audit24c.out: $(objpfx)tst-auditmod24c.so $(objpfx)tst-audit24c: $(objpfx)tst-audit24amod1.so \ $(objpfx)tst-audit24amod2.so tst-audit24c-ENV = LD_BIND_NOW=1 LD_AUDIT=$(objpfx)tst-auditmod24c.so -LDFLAGS-tst-audit24b = -Wl,-z,lazy +LDFLAGS-tst-audit24c = -Wl,-z,lazy $(objpfx)tst-audit24d.out: $(objpfx)tst-auditmod24d.so $(objpfx)tst-audit24d: $(objpfx)tst-audit24dmod1.so \ diff --git a/elf/dl-audit.c b/elf/dl-audit.c index 794bfd45cd..efc0492474 100644 --- a/elf/dl-audit.c +++ b/elf/dl-audit.c @@ -257,7 +257,8 @@ _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result, reloc_result->flags = flags; } - DL_FIXUP_BINDNOW_RELOC (value, new_value, sym.st_value); + if (flags & LA_SYMB_ALTVALUE) + DL_FIXUP_BINDNOW_RELOC (value, new_value, sym.st_value); } void diff --git a/elf/dl-map-segments.h b/elf/dl-map-segments.h index 172692b120..fd24cf5d01 100644 --- a/elf/dl-map-segments.h +++ b/elf/dl-map-segments.h @@ -113,6 +113,9 @@ _dl_map_segments (struct link_map *l, int fd, unallocated. Then jump into the normal segment-mapping loop to handle the portion of the segment past the end of the file mapping. */ + if (__glibc_unlikely (loadcmds[nloadcmds - 1].mapstart < + c->mapend)) + return N_("ELF load command address/offset not page-aligned"); if (__glibc_unlikely (__mprotect ((caddr_t) (l->l_addr + c->mapend), loadcmds[nloadcmds - 1].mapstart - c->mapend, diff --git a/elf/tst-auditmod24a.c b/elf/tst-auditmod24a.c index d8e88f3984..3075dfae2f 100644 --- a/elf/tst-auditmod24a.c +++ b/elf/tst-auditmod24a.c @@ -110,5 +110,7 @@ la_symbind32 (Elf32_Sym *sym, unsigned int ndx, return sym->st_value; } - abort (); + if (symname[0] != '\0') + abort (); + return sym->st_value; } diff --git a/elf/tst-auditmod24d.c b/elf/tst-auditmod24d.c index 8c803ecc0a..badc6be451 100644 --- a/elf/tst-auditmod24d.c +++ b/elf/tst-auditmod24d.c @@ -116,5 +116,7 @@ la_symbind32 (Elf32_Sym *sym, unsigned int ndx, } } - abort (); + if (symname[0] != '\0') + abort (); + return sym->st_value; } diff --git a/elf/tst-auditmod25.c b/elf/tst-auditmod25.c index 526f5c54bc..20640a8daf 100644 --- a/elf/tst-auditmod25.c +++ b/elf/tst-auditmod25.c @@ -72,7 +72,7 @@ la_symbind32 (Elf32_Sym *sym, unsigned int ndx, unsigned int *flags, const char *symname) #endif { - if (*refcook != -1 && *defcook != -1) + if (*refcook != -1 && *defcook != -1 && symname[0] != '\0') fprintf (stderr, "la_symbind: %s %u\n", symname, *flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT) ? 1 : 0); return sym->st_value; diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c index 3b0412b405..18698bbe94 100644 --- a/locale/programs/ld-monetary.c +++ b/locale/programs/ld-monetary.c @@ -196,21 +196,105 @@ No definition for %s category found"), "LC_MONETARY"); } } + /* Generally speaking there are 3 standards the define the default, + warning, and error behaviour of LC_MONETARY. They are ISO/IEC TR 30112, + ISO/IEC 9899:2018 (ISO C17), and POSIX.1-2017. Within 30112 we have the + definition of a standard i18n FDCC-set, which for LC_MONETARY has the + following default values: + int_curr_symbol "" + currency_symbol "" + mon_decimal_point "<U002C>" i.e. "," + mon_thousand_sep "" + mon_grouping "\177" i.e. CHAR_MAX + positive_sign "" + negative_sign "<U002E>" i.e. "." + int_frac_digits -1 + frac_digits -1 + p_cs_precedes -1 + p_sep_by_space -1 + n_cs_precedes -1 + n_sep_by_space -1 + p_sign_posn -1 + n_sign_posn -1 + Under 30112 a keyword that is not provided implies an empty string "" + for string values or a -1 for integer values, and indicates the value + is unspecified with no default implied. No errors are considered. + The exception is mon_grouping which is a string with a terminating + CHAR_MAX. + For POSIX Issue 7 we have: + https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html + and again values not provided default to "" or -1, and indicate the value + is not available to the locale. The exception is mon_grouping which is + a string with a terminating CHAR_MAX. For the POSIX locale the values of + LC_MONETARY should be: + int_curr_symbol "" + currency_symbol "" + mon_decimal_point "" + mon_thousands_sep "" + mon_grouping "\177" i.e. CHAR_MAX + positive_sign "" + negative_sign "" + int_frac_digits -1 + frac_digits -1 + p_cs_precedes -1 + p_sep_by_space -1 + n_cs_precedes -1 + n_sep_by_space -1 + p_sign_posn -1 + n_sign_posn -1 + int_p_cs_precedes -1 + int_p_sep_by_space -1 + int_n_cs_precedes -1 + int_n_sep_by_space -1 + int_p_sign_posn -1 + int_n_sign_posn -1 + Like with 30112, POSIX also considers no error if the keywords are + missing, only that if the cateory as a whole is missing the referencing + of the category results in unspecified behaviour. + For ISO C17 there is no default value provided, but the localeconv + specification in 7.11.2.1 admits that members of char * type may point + to "" to indicate a value is not available or is of length zero. + The exception is decimal_point (not mon_decimal_point) which must be a + defined non-empty string. The values of char, which are generally + mapped to integer values in 30112 and POSIX, must be non-negative + numbers that map to CHAR_MAX when a value is not available in the + locale. + In ISO C17 for the "C" locale all values are empty strings "", or + CHAR_MAX, with the exception of decimal_point which is "." (defined + in LC_NUMERIC). ISO C17 makes no exception for mon_grouping like + 30112 and POSIX, but a value of "" is functionally equivalent to + "\177" since neither defines a grouping (though the latter terminates + the grouping). + + Lastly, we must consider the legacy C/POSIX locale that implemented + as a builtin in glibc and wether a default value mapping to the + C/POSIX locale may benefit the user from a compatibility perspective. + + Thus given 30112, POSIX, ISO C, and the builtin C/POSIX locale we + need to pick appropriate defaults below. */ + + /* The members of LC_MONETARY are handled in the order of their definition + in locale/categories.def. Please keep them in that order. */ + + /* The purpose of TEST_ELEM is to define a default value for the fields + in the category if the field was not defined in the cateory. If the + category was present but we didn't see a definition for the field then + we also issue a warning, otherwise the only warning you get is the one + earlier when a default category is created (completely missing category). + This missing field warning is glibc-specific since no standard requires + this warning, but we consider it valuable to print a warning for all + missing fields in the category. */ #define TEST_ELEM(cat, initval) \ if (monetary->cat == NULL) \ { \ if (! nothing) \ - record_error (0, 0, _("%s: field `%s' not defined"), \ - "LC_MONETARY", #cat); \ + record_warning (_("%s: field `%s' not defined"), \ + "LC_MONETARY", #cat); \ monetary->cat = initval; \ } + /* Keyword: int_curr_symbol. */ TEST_ELEM (int_curr_symbol, ""); - TEST_ELEM (currency_symbol, ""); - TEST_ELEM (mon_thousands_sep, ""); - TEST_ELEM (positive_sign, ""); - TEST_ELEM (negative_sign, ""); - /* The international currency symbol must come from ISO 4217. */ if (monetary->int_curr_symbol != NULL) { @@ -247,41 +331,63 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), } } - /* The decimal point must not be empty. This is not said explicitly - in POSIX but ANSI C (ISO/IEC 9899) says in 4.4.2.1 it has to be - != "". */ + /* Keyword: currency_symbol */ + TEST_ELEM (currency_symbol, ""); + + /* Keyword: mon_decimal_point */ + /* ISO C17 7.11.2.1.3 explicitly allows mon_decimal_point to be the + empty string e.g. "". This indicates the value is not available in the + current locale or is of zero length. However, if the value was never + defined then we issue a warning and use a glibc-specific default. ISO + 30112 in the i18n FDCC-Set uses <U002C> ",", and POSIX Issue 7 in the + POSIX locale uses "". It is specific to glibc that the default is <U002E> + "."; we retain this existing behaviour for backwards compatibility. */ if (monetary->mon_decimal_point == NULL) { if (! nothing) - record_error (0, 0, _("%s: field `%s' not defined"), - "LC_MONETARY", "mon_decimal_point"); + record_warning (_("%s: field `%s' not defined, using defaults"), + "LC_MONETARY", "mon_decimal_point"); monetary->mon_decimal_point = "."; monetary->mon_decimal_point_wc = L'.'; } - else if (monetary->mon_decimal_point[0] == '\0' && ! be_quiet && ! nothing) + + /* Keyword: mon_thousands_sep */ + if (monetary->mon_thousands_sep == NULL) { - record_error (0, 0, _("\ -%s: value for field `%s' must not be an empty string"), - "LC_MONETARY", "mon_decimal_point"); + if (! nothing) + record_warning (_("%s: field `%s' not defined, using defaults"), + "LC_MONETARY", "mon_thousands_sep"); + monetary->mon_thousands_sep = ""; + monetary->mon_thousands_sep_wc = L'\0'; } + /* Keyword: mon_grouping */ if (monetary->mon_grouping_len == 0) { if (! nothing) - record_error (0, 0, _("%s: field `%s' not defined"), - "LC_MONETARY", "mon_grouping"); - + record_warning (_("%s: field `%s' not defined"), + "LC_MONETARY", "mon_grouping"); + /* Missing entries are given 1 element in their bytearray with + a value of CHAR_MAX which indicates that "No further grouping + is to be performed" (functionally equivalent to ISO C's "C" + locale default of ""). */ monetary->mon_grouping = (char *) "\177"; monetary->mon_grouping_len = 1; } + /* Keyword: positive_sign */ + TEST_ELEM (positive_sign, ""); + + /* Keyword: negative_sign */ + TEST_ELEM (negative_sign, ""); + #undef TEST_ELEM #define TEST_ELEM(cat, min, max, initval) \ if (monetary->cat == -2) \ { \ if (! nothing) \ - record_error (0, 0, _("%s: field `%s' not defined"), \ - "LC_MONETARY", #cat); \ + record_warning (_("%s: field `%s' not defined"), \ + "LC_MONETARY", #cat); \ monetary->cat = initval; \ } \ else if ((monetary->cat < min || monetary->cat > max) \ @@ -300,16 +406,11 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), TEST_ELEM (p_sign_posn, -1, 4, -1); TEST_ELEM (n_sign_posn, -1, 4, -1); - /* The non-POSIX.2 extensions are optional. */ - if (monetary->duo_int_curr_symbol == NULL) - monetary->duo_int_curr_symbol = monetary->int_curr_symbol; - if (monetary->duo_currency_symbol == NULL) - monetary->duo_currency_symbol = monetary->currency_symbol; - - if (monetary->duo_int_frac_digits == -2) - monetary->duo_int_frac_digits = monetary->int_frac_digits; - if (monetary->duo_frac_digits == -2) - monetary->duo_frac_digits = monetary->frac_digits; + /* Keyword: crncystr */ + monetary->crncystr = (char *) xmalloc (strlen (monetary->currency_symbol) + + 2); + monetary->crncystr[0] = monetary->p_cs_precedes ? '-' : '+'; + strcpy (&monetary->crncystr[1], monetary->currency_symbol); #undef TEST_ELEM #define TEST_ELEM(cat, alt, min, max) \ @@ -327,6 +428,17 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), TEST_ELEM (int_p_sign_posn, p_sign_posn, -1, 4); TEST_ELEM (int_n_sign_posn, n_sign_posn, -1, 4); + /* The non-POSIX.2 extensions are optional. */ + if (monetary->duo_int_curr_symbol == NULL) + monetary->duo_int_curr_symbol = monetary->int_curr_symbol; + if (monetary->duo_currency_symbol == NULL) + monetary->duo_currency_symbol = monetary->currency_symbol; + + if (monetary->duo_int_frac_digits == -2) + monetary->duo_int_frac_digits = monetary->int_frac_digits; + if (monetary->duo_frac_digits == -2) + monetary->duo_frac_digits = monetary->frac_digits; + TEST_ELEM (duo_p_cs_precedes, p_cs_precedes, -1, 1); TEST_ELEM (duo_p_sep_by_space, p_sep_by_space, -1, 2); TEST_ELEM (duo_n_cs_precedes, n_cs_precedes, -1, 1); @@ -349,17 +461,15 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), if (monetary->duo_valid_to == 0) monetary->duo_valid_to = 99991231; + /* Keyword: conversion_rate */ if (monetary->conversion_rate[0] == 0) { monetary->conversion_rate[0] = 1; monetary->conversion_rate[1] = 1; } - /* Create the crncystr entry. */ - monetary->crncystr = (char *) xmalloc (strlen (monetary->currency_symbol) - + 2); - monetary->crncystr[0] = monetary->p_cs_precedes ? '-' : '+'; - strcpy (&monetary->crncystr[1], monetary->currency_symbol); + /* A value for monetary-decimal-point-wc was set when + monetary_decimal_point was set, likewise for monetary-thousands-sep-wc. */ } diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c index 45408c26c1..eeb2fa6ffe 100644 --- a/locale/programs/locarchive.c +++ b/locale/programs/locarchive.c @@ -1397,7 +1397,7 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) { char fullname[fnamelen + 2 * strlen (d->d_name) + 7]; - if (d_type == DT_UNKNOWN) + if (d_type == DT_UNKNOWN || d_type == DT_LNK) { strcpy (stpcpy (stpcpy (fullname, fname), "/"), d->d_name); diff --git a/localedata/Makefile b/localedata/Makefile index 9ae2e5c161..7741ac3b5e 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -468,11 +468,11 @@ define build-one-locale endef $(INSTALL-SUPPORTED-LOCALE-ARCHIVE): install-locales-dir - @flags="-c"; \ + @flags=""; \ $(build-one-locale) $(INSTALL-SUPPORTED-LOCALE-FILES): install-locales-dir - @flags="-c --no-archive --no-hard-links"; \ + @flags="--no-archive --no-hard-links"; \ $(build-one-locale) tst-setlocale-ENV = LC_ALL=ja_JP.EUC-JP diff --git a/localedata/gen-locale.sh b/localedata/gen-locale.sh index 7fce35f212..8053c816a6 100644 --- a/localedata/gen-locale.sh +++ b/localedata/gen-locale.sh @@ -54,8 +54,14 @@ modifier=`echo $locfile|sed 's|[^.]*[.]\([^@ ]*\)\(@[^ ]*\)\?/LC_CTYPE|\2|'` echo "Generating locale $locale.$charmap: this might take a while..." -# Run quietly and force output. -flags="--quiet -c" +# Do not force output with '-c', all locales should compile without +# warning or errors. There is likewise no need to run quietly with +# '--quiet' since all locales should compile without additional +# diagnostics. If there are messages printed then we want to see +# them, fix them, and the associated error or warning. During +# development it may be beneficialy to put '--quiet -c' here to allow +# you to develop in-progress locales. +flags="" # For SJIS the charmap is SHIFT_JIS. We just want the locale to have # a slightly nicer name instead of using "*.SHIFT_SJIS", but that diff --git a/nptl/unwind.c b/nptl/unwind.c index c3563e3467..33b0d87579 100644 --- a/nptl/unwind.c +++ b/nptl/unwind.c @@ -25,7 +25,7 @@ #include <jmpbuf-unwind.h> #include <shlib-compat.h> -#ifdef _STACK_GROWS_DOWN +#if _STACK_GROWS_DOWN # define FRAME_LEFT(frame, other, adj) \ ((uintptr_t) frame - adj >= (uintptr_t) other - adj) #elif _STACK_GROWS_UP diff --git a/posix/tst-spawn6.c b/posix/tst-spawn6.c index 911e90a461..044abd8535 100644 --- a/posix/tst-spawn6.c +++ b/posix/tst-spawn6.c @@ -29,7 +29,14 @@ #include <support/check.h> #include <support/xunistd.h> #include <sys/wait.h> +#include <sys/ioctl.h> #include <stdlib.h> +#include <termios.h> + +#ifndef PATH_MAX +# define PATH_MAX 1024 +#endif +static char ptmxpath[PATH_MAX]; static int handle_restart (const char *argv1, const char *argv2) @@ -115,7 +122,7 @@ run_subprogram (int argc, char *argv[], const posix_spawnattr_t *attr, } static int -do_test (int argc, char *argv[]) +run_test (int argc, char *argv[]) { /* We must have either: - four parameters left if called initially: @@ -127,16 +134,7 @@ do_test (int argc, char *argv[]) + --setgrpr optional */ - if (restart) - return handle_restart (argv[1], argv[2]); - - int tcfd = open64 (_PATH_TTY, O_RDONLY, 0600); - if (tcfd == -1) - { - if (errno == ENXIO) - FAIL_UNSUPPORTED ("terminal not available, skipping test"); - FAIL_EXIT1 ("open64 (\"%s\", 0x%x, 0600): %m", _PATH_TTY, O_RDONLY); - } + int tcfd = xopen (ptmxpath, O_RDONLY, 0600); /* Check setting the controlling terminal without changing the group. */ { @@ -198,5 +196,47 @@ do_test (int argc, char *argv[]) return 0; } +static int +do_test (int argc, char *argv[]) +{ + if (restart) + return handle_restart (argv[1], argv[2]); + + pid_t pid = xfork (); + if (pid == 0) + { + /* Create a pseudo-terminal to avoid interfering with the one using by + test itself, creates a new session (so there is no controlling + terminal), and set the pseudo-terminal as the controlling one. */ + int ptmx = posix_openpt (0); + if (ptmx == -1) + { + if (errno == ENXIO) + FAIL_UNSUPPORTED ("terminal not available, skipping test"); + FAIL_EXIT1 ("posix_openpt (0): %m"); + } + TEST_VERIFY_EXIT (grantpt (ptmx) == 0); + TEST_VERIFY_EXIT (unlockpt (ptmx) == 0); + + TEST_VERIFY_EXIT (setsid () != -1); + TEST_VERIFY_EXIT (ioctl (ptmx, TIOCSCTTY, NULL) == 0); + while (dup2 (ptmx, STDIN_FILENO) == -1 && errno == EBUSY) + ; + while (dup2 (ptmx, STDOUT_FILENO) == -1 && errno == EBUSY) + ; + while (dup2 (ptmx, STDERR_FILENO) == -1 && errno == EBUSY) + ; + TEST_VERIFY_EXIT (ptsname_r (ptmx, ptmxpath, sizeof ptmxpath) == 0); + xclose (ptmx); + + run_test (argc, argv); + _exit (0); + } + int status; + xwaitpid (pid, &status, 0); + TEST_VERIFY (WIFEXITED (status)); + exit (0); +} + #define TEST_FUNCTION_ARGV do_test #include <support/test-driver.c> diff --git a/resolv/Makefile b/resolv/Makefile index c465479e8b..438672786f 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -79,11 +79,6 @@ generate := mtrace-tst-leaks.out tst-leaks.mtrace tst-leaks2.mtrace extra-libs := libresolv libnss_dns ifeq ($(have-thread-library),yes) routines += gai_sigqueue -endif - -ifeq ($(have-GLIBC_2.34)$(have-thread-library),yesyes) -# Empty compatibility library for old binaries. -extra-libs += libanl tests += \ tst-bug18665 \ @@ -144,7 +139,8 @@ xtests += tst-resolv-qtypes # This test has dropped packet tests and runs for a long time. xtests += tst-resolv-rotate -endif +endif # $(have-thread-library) + extra-libs-others = $(extra-libs) libresolv-routines := \ base64 \ @@ -168,6 +164,13 @@ libresolv-routines := \ resolv-deprecated \ # libresolv-routines +ifeq ($(have-GLIBC_2.34)$(have-thread-library),yesyes) +# Empty compatibility library for old binaries. +extra-libs += libanl +libanl-routines += libanl-compat +libanl-shared-only-routines += libanl-compat +endif + $(libanl-routines-var) += \ gai_cancel \ gai_error \ @@ -177,9 +180,6 @@ $(libanl-routines-var) += \ getaddrinfo_a \ # $(libanl-routines-var) -libanl-routines += libanl-compat -libanl-shared-only-routines += libanl-compat - # Pretend that libanl.so is a linker script, so that the symbolic link # is not installed. install-lib-ldscripts = libanl.so diff --git a/string/test-strncmp.c b/string/test-strncmp.c index e7d5edea39..22b7dfa73b 100644 --- a/string/test-strncmp.c +++ b/string/test-strncmp.c @@ -434,6 +434,18 @@ check3 (void) } } +static void +check4 (void) +{ + const CHAR *s1 = L ("abc"); + CHAR *s2 = STRDUP (s1); + + FOR_EACH_IMPL (impl, 0) + check_result (impl, s1, s2, SIZE_MAX, 0); + + free (s2); +} + int test_main (void) { @@ -444,6 +456,7 @@ test_main (void) check1 (); check2 (); check3 (); + check4 (); printf ("%23s", ""); FOR_EACH_IMPL (impl, 0) diff --git a/sysdeps/hppa/dl-fptr.c b/sysdeps/hppa/dl-fptr.c index 2584557c4f..9ed21602d6 100644 --- a/sysdeps/hppa/dl-fptr.c +++ b/sysdeps/hppa/dl-fptr.c @@ -26,6 +26,7 @@ #include <ldsodefs.h> #include <elf/dynamic-link.h> #include <dl-fptr.h> +#include <dl-runtime.h> #include <dl-unmap-segments.h> #include <atomic.h> #include <libc-pointer-arith.h> @@ -351,21 +352,20 @@ _dl_lookup_address (const void *address) { ElfW(Addr) addr = (ElfW(Addr)) address; ElfW(Word) reloc_arg; - volatile unsigned int *desc; - unsigned int *gptr; + unsigned int *desc, *gptr; /* Return ADDR if the least-significant two bits of ADDR are not consistent with ADDR being a linker defined function pointer. The normal value for a code address in a backtrace is 3. */ - if (((unsigned int) addr & 3) != 2) + if (((uintptr_t) addr & 3) != 2) return addr; /* Handle special case where ADDR points to page 0. */ - if ((unsigned int) addr < 4096) + if ((uintptr_t) addr < 4096) return addr; /* Clear least-significant two bits from descriptor address. */ - desc = (unsigned int *) ((unsigned int) addr & ~3); + desc = (unsigned int *) ((uintptr_t) addr & ~3); if (!_dl_read_access_allowed (desc)) return addr; @@ -376,7 +376,7 @@ _dl_lookup_address (const void *address) /* Then load first word of candidate descriptor. It should be a pointer with word alignment and point to memory that can be read. */ gptr = (unsigned int *) desc[0]; - if (((unsigned int) gptr & 3) != 0 + if (((uintptr_t) gptr & 3) != 0 || !_dl_read_access_allowed (gptr)) return addr; @@ -400,10 +400,11 @@ _dl_lookup_address (const void *address) /* If gp has been resolved, we need to hunt for relocation offset. */ if (!(reloc_arg & PA_GP_RELOC)) - reloc_arg = _dl_fix_reloc_arg (addr, l); + reloc_arg = _dl_fix_reloc_arg ((struct fdesc *) addr, l); _dl_fixup (l, reloc_arg); } return (ElfW(Addr)) desc[0]; } +rtld_hidden_def (_dl_lookup_address) diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h index 8da2412fea..de0a3b78e8 100644 --- a/sysdeps/hppa/dl-lookupcfg.h +++ b/sysdeps/hppa/dl-lookupcfg.h @@ -30,6 +30,7 @@ rtld_hidden_proto (_dl_symbol_address) #define DL_SYMBOL_ADDRESS(map, ref) _dl_symbol_address(map, ref) Elf32_Addr _dl_lookup_address (const void *address); +rtld_hidden_proto (_dl_lookup_address) #define DL_LOOKUP_ADDRESS(addr) _dl_lookup_address ((const void *) addr) @@ -79,7 +80,9 @@ void attribute_hidden _dl_unmap (struct link_map *map); /* Extract the code address from a fixup value */ #define DL_FIXUP_VALUE_CODE_ADDR(value) ((value).ip) #define DL_FIXUP_VALUE_ADDR(value) ((uintptr_t) &(value)) -#define DL_FIXUP_ADDR_VALUE(addr) (*(struct fdesc *) (addr)) +/* Clear the plabel bit to get the actual address of the descriptor. */ +#define DL_FIXUP_ADDR_VALUE(addr) \ + (*(DL_FIXUP_VALUE_TYPE *) ((uintptr_t) (addr) & ~2)) #define DL_FIXUP_BINDNOW_ADDR_VALUE(addr) (addr) -#define DL_FIXUP_BINDNOW_RELOC(value, new_value, st_value) \ - (*value) = *(struct fdesc *) (st_value) +#define DL_FIXUP_BINDNOW_RELOC(value, new_value, st_value) \ + *(value) = *(DL_FIXUP_VALUE_TYPE *) ((uintptr_t) (new_value) & ~2) diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h index da4d57d2e4..7b7a697cbb 100644 --- a/sysdeps/hppa/dl-machine.h +++ b/sysdeps/hppa/dl-machine.h @@ -176,6 +176,15 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], Elf32_Addr i[2]; } sig = {{0x00,0xc0,0xff,0xee, 0xde,0xad,0xbe,0xef}}; + /* Initialize dp register for main executable. */ + if (l->l_main_map) + { + register Elf32_Addr dp asm ("%r27"); + + dp = D_PTR (l, l_info[DT_PLTGOT]); + asm volatile ("" : : "r" (dp)); + } + /* If we don't have a PLT we can just skip all this... */ if (__builtin_expect (l->l_info[DT_JMPREL] == NULL,0)) return lazy; @@ -338,16 +347,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], its return value is the user program's entry point. */ #define RTLD_START \ -/* Set up dp for any non-PIC lib constructors that may be called. */ \ -static struct link_map * __attribute__((used)) \ -set_dp (struct link_map *map) \ -{ \ - register Elf32_Addr dp asm ("%r27"); \ - dp = D_PTR (map, l_info[DT_PLTGOT]); \ - asm volatile ("" : : "r" (dp)); \ - return map; \ -} \ - \ asm ( \ " .text\n" \ " .globl _start\n" \ @@ -447,14 +446,11 @@ asm ( \ " stw %r24,-44(%sp)\n" \ \ ".Lnofix:\n" \ + /* Call _dl_init(main_map, argc, argv, envp). */ \ " addil LT'_rtld_local,%r19\n" \ " ldw RT'_rtld_local(%r1),%r26\n" \ -" bl set_dp, %r2\n" \ " ldw 0(%r26),%r26\n" \ \ - /* Call _dl_init(_dl_loaded, argc, argv, envp). */ \ -" copy %r28,%r26\n" \ - \ /* envp = argv + argc + 1 */ \ " sh2add %r25,%r24,%r23\n" \ " bl _dl_init,%r2\n" \ diff --git a/sysdeps/hppa/dl-runtime.c b/sysdeps/hppa/dl-runtime.c index 8b2ee58e37..192a6bee03 100644 --- a/sysdeps/hppa/dl-runtime.c +++ b/sysdeps/hppa/dl-runtime.c @@ -25,8 +25,7 @@ return that to the caller. The caller will continue on to call _dl_fixup with the relocation offset. */ -ElfW(Word) -attribute_hidden __attribute ((noinline)) DL_ARCH_FIXUP_ATTRIBUTE +ElfW(Word) __attribute ((noinline)) DL_ARCH_FIXUP_ATTRIBUTE _dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l) { Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type; @@ -52,3 +51,4 @@ _dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l) ABORT_INSTRUCTION; return 0; } +rtld_hidden_def (_dl_fix_reloc_arg) diff --git a/sysdeps/hppa/dl-runtime.h b/sysdeps/hppa/dl-runtime.h index d4da46079b..5ced8e14e9 100644 --- a/sysdeps/hppa/dl-runtime.h +++ b/sysdeps/hppa/dl-runtime.h @@ -17,6 +17,9 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +ElfW(Word) _dl_fix_reloc_arg (struct fdesc *, struct link_map *); +rtld_hidden_proto (_dl_fix_reloc_arg) + /* Clear PA_GP_RELOC bit in relocation offset. */ static inline uintptr_t reloc_offset (uintptr_t plt0, uintptr_t pltn) diff --git a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c index 82171bf325..dfc8c2beff 100644 --- a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c +++ b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c @@ -16,9 +16,9 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ -#include <kernel-features.h> +#include <bits/timesize.h> -#ifndef __ASSUME_TIME64_SYSCALLS +#if __TIMESIZE != 64 # include <stdint.h> # include <string.h> # include <sys/socket.h> diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index 4798cc337e..d1ea074f0d 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -44,15 +44,14 @@ __get_nprocs_sched (void) int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size, cpu_bits); if (r > 0) - return CPU_COUNT_S (cpu_bits_size, (cpu_set_t*) cpu_bits); + return CPU_COUNT_S (r, (cpu_set_t*) cpu_bits); else if (r == -EINVAL) /* The input buffer is still not enough to store the number of cpus. This is an arbitrary values assuming such systems should be rare and there is no offline cpus. */ return max_num_cpus; - /* Some other error. 2 is conservative (not a uniprocessor system, so - atomics are needed). */ - return 2; + /* Some other error. */ + return 0; } static char * @@ -108,22 +107,19 @@ next_line (int fd, char *const buffer, char **cp, char **re, } static int -get_nproc_stat (char *buffer, size_t buffer_size) +get_nproc_stat (void) { + enum { buffer_size = 1024 }; + char buffer[buffer_size]; char *buffer_end = buffer + buffer_size; char *cp = buffer_end; char *re = buffer_end; - - /* Default to an SMP system in case we cannot obtain an accurate - number. */ - int result = 2; + int result = 0; const int flags = O_RDONLY | O_CLOEXEC; int fd = __open_nocancel ("/proc/stat", flags); if (fd != -1) { - result = 0; - char *l; while ((l = next_line (fd, buffer, &cp, &re, buffer_end)) != NULL) /* The current format of /proc/stat has all the cpu* entries @@ -139,8 +135,8 @@ get_nproc_stat (char *buffer, size_t buffer_size) return result; } -int -__get_nprocs (void) +static int +get_nprocs_cpu_online (void) { enum { buffer_size = 1024 }; char buffer[buffer_size]; @@ -179,7 +175,8 @@ __get_nprocs (void) } } - result += m - n + 1; + if (m >= n) + result += m - n + 1; l = endp; if (l < re && *l == ',') @@ -188,28 +185,18 @@ __get_nprocs (void) while (l < re && *l != '\n'); __close_nocancel_nostatus (fd); - - if (result > 0) - return result; } - return get_nproc_stat (buffer, buffer_size); + return result; } -libc_hidden_def (__get_nprocs) -weak_alias (__get_nprocs, get_nprocs) - -/* On some architectures it is possible to distinguish between configured - and active cpus. */ -int -__get_nprocs_conf (void) +static int +get_nprocs_cpu (void) { - /* Try to use the sysfs filesystem. It has actual information about - online processors. */ + int count = 0; DIR *dir = __opendir ("/sys/devices/system/cpu"); if (dir != NULL) { - int count = 0; struct dirent64 *d; while ((d = __readdir64 (dir)) != NULL) @@ -224,12 +211,57 @@ __get_nprocs_conf (void) __closedir (dir); - return count; } + return count; +} - enum { buffer_size = 1024 }; - char buffer[buffer_size]; - return get_nproc_stat (buffer, buffer_size); +static int +get_nprocs_fallback (void) +{ + int result; + + /* Try /proc/stat first. */ + result = get_nproc_stat (); + if (result != 0) + return result; + + /* Try sched_getaffinity. */ + result = __get_nprocs_sched (); + if (result != 0) + return result; + + /* We failed to obtain an accurate number. Be conservative: return + the smallest number meaning that this is not a uniprocessor system, + so atomics are needed. */ + return 2; +} + +int +__get_nprocs (void) +{ + /* Try /sys/devices/system/cpu/online first. */ + int result = get_nprocs_cpu_online (); + if (result != 0) + return result; + + /* Fall back to /proc/stat and sched_getaffinity. */ + return get_nprocs_fallback (); +} +libc_hidden_def (__get_nprocs) +weak_alias (__get_nprocs, get_nprocs) + +/* On some architectures it is possible to distinguish between configured + and active cpus. */ +int +__get_nprocs_conf (void) +{ + /* Try /sys/devices/system/cpu/ first. */ + int result = get_nprocs_cpu (); + if (result != 0) + return result; + + /* Fall back to /proc/stat and sched_getaffinity. */ + return get_nprocs_fallback (); } libc_hidden_def (__get_nprocs_conf) weak_alias (__get_nprocs_conf, get_nprocs_conf) diff --git a/sysdeps/unix/sysv/linux/hppa/getcontext.S b/sysdeps/unix/sysv/linux/hppa/getcontext.S index 1e73587f13..dcdf986f2d 100644 --- a/sysdeps/unix/sysv/linux/hppa/getcontext.S +++ b/sysdeps/unix/sysv/linux/hppa/getcontext.S @@ -21,22 +21,28 @@ #include "ucontext_i.h" - /* Trampoline function. Non-standard calling ABI. */ + /* Trampoline function. Non-standard calling ABI. */ /* Can not use ENTRY(__getcontext_ret) here. */ .type __getcontext_ret, @function .hidden __getcontext_ret __getcontext_ret: .proc .callinfo FRAME=0,NO_CALLS - /* r26-r23 contain original r3-r6, but because setcontext - does not reload r3-r6 (it's using them as temporaries) - we must save them elsewhere and swap them back in. */ - copy %r23, %r3 - copy %r24, %r4 - copy %r25, %r5 - copy %r26, %r6 - /* r20 contains original return pointer. */ - bv 0(%r20) + /* Because setcontext does not reload r3-r6 (it's using them + as temporaries), we must load them ourself. */ + ldw oR3(%r26), %r3 + ldw oR4(%r26), %r4 + ldw oR5(%r26), %r5 + ldw oR6(%r26), %r6 + + /* Also reload registers clobbered by $$dyncall. */ + ldw oR21(%r26), %r21 + ldw oR22(%r26), %r22 + ldw oR31(%r26), %r31 + + /* oR0 contains original return pointer. */ + ldw oR0(%r26), %rp + bv 0(%rp) copy %r0, %ret0 .procend .size __getcontext_ret, .-__getcontext_ret @@ -64,13 +70,13 @@ ENTRY(__getcontext) stw %r17, oR17(%r26) stw %r18, oR18(%r26) stw %r19, oR19(%r26) - /* stw %r20, oR20(%r26) - used for trampoline. */ + stw %r20, oR20(%r26) stw %r21, oR21(%r26) stw %r22, oR22(%r26) - /* stw %r23, oR23(%r26) - used for trampoline. */ - /* stw %r24, oR24(%r26) - used for trampoline. */ - /* stw %r25, oR25(%r26) - used for trampoline. */ - /* stw %r26, oR26(%r26) - used for trampoline. */ + stw %r23, oR23(%r26) + stw %r24, oR24(%r26) + stw %r25, oR25(%r26) + stw %r26, oR26(%r26) stw %r27, oR27(%r26) stw %r28, oR28(%r26) stw %r29, oR29(%r26) @@ -89,7 +95,10 @@ ENTRY(__getcontext) stw %r0, oIASQ1(%r26) stw %r0, oIAOQ0(%r26) stw %r0, oIAOQ1(%r26) - stw %r0, oSAR(%r26) /* used as flag in swapcontext(). */ + + /* Save SAR register. */ + mfctl %sar, %r1 + stw %r1, oSAR(%r26) /* MSB used as flag in swapcontext(). */ /* Store floating-point regs. */ @@ -137,15 +146,12 @@ ENTRY(__getcontext) stw %r19, -32(%sp) .cfi_offset 19, 32 #endif + stw %ret1, -60(%sp) + .cfi_offset 29, 4 /* Set up the trampoline registers. - r20, r23, r24, r25, r26 and r2 are clobbered - by call to getcontext() anyway. Reuse them. */ - stw %r2, oR20(%r26) - stw %r3, oR23(%r26) - stw %r4, oR24(%r26) - stw %r5, oR25(%r26) - stw %r6, oR26(%r26) + Use oR0 context slot to save return value. */ + stw %r2, oR0(%r26) #ifdef PIC addil LT%__getcontext_ret, %r19 ldw RT%__getcontext_ret(%r1), %r1 @@ -167,6 +173,7 @@ ENTRY(__getcontext) #ifdef PIC ldw -32(%sp), %r19 #endif + ldw -60(%sp), %ret1 bv %r0(%r2) ldwm -64(%sp), %r4 END(__getcontext) diff --git a/sysdeps/unix/sysv/linux/hppa/setcontext.S b/sysdeps/unix/sysv/linux/hppa/setcontext.S index bc4872c8e2..dfa794ad5c 100644 --- a/sysdeps/unix/sysv/linux/hppa/setcontext.S +++ b/sysdeps/unix/sysv/linux/hppa/setcontext.S @@ -33,6 +33,8 @@ ENTRY(__setcontext) stw %r19, -32(%sp) .cfi_offset 19, 32 #endif + stw %ret1, -60(%sp) + .cfi_offset 29, 4 /* Save ucp. */ copy %r26, %r3 @@ -73,7 +75,7 @@ ENTRY(__setcontext) ldw oR18(%r3), %r18 ldw oR19(%r3), %r19 ldw oR20(%r3), %r20 - ldw oR21(%r3), %r21 + ldw oR21(%r3), %r21 /* maybe clobbered by dyncall */ /* ldw oR22(%r3), %r22 - dyncall arg. */ ldw oR23(%r3), %r23 ldw oR24(%r3), %r24 @@ -85,6 +87,10 @@ ENTRY(__setcontext) ldw oR30(%r3), %sp /* ldw oR31(%r3), %r31 - dyncall scratch register */ + /* Restore SAR register. */ + ldw oSAR(%r3), %r22 + mtsar %r22 + /* Restore floating-point registers. */ ldo oFPREGS31(%r3), %r22 fldds 0(%r22), %fr31 @@ -154,6 +160,7 @@ ENTRY(__setcontext) #ifdef PIC ldw -32(%r30), %r19 #endif + ldw -60(%r30), %ret1 bv %r0(%r2) ldwm -64(%r30), %r3 L(pseudo_end): diff --git a/sysdeps/unix/sysv/linux/hppa/swapcontext.c b/sysdeps/unix/sysv/linux/hppa/swapcontext.c index 5cbe00f1e9..e5bf6c9933 100644 --- a/sysdeps/unix/sysv/linux/hppa/swapcontext.c +++ b/sysdeps/unix/sysv/linux/hppa/swapcontext.c @@ -17,6 +17,7 @@ <https://www.gnu.org/licenses/>. */ #include <ucontext.h> +#include "ucontext_i.h" extern int __getcontext (ucontext_t *ucp); extern int __setcontext (const ucontext_t *ucp); @@ -24,17 +25,57 @@ extern int __setcontext (const ucontext_t *ucp); int __swapcontext (ucontext_t *oucp, const ucontext_t *ucp) { + /* Save rp for debugger. */ + asm ("stw %rp,-20(%sp)"); + asm (".cfi_offset 2, -20"); + + /* Copy rp to ret0 (r28). */ + asm ("copy %rp,%ret0"); + + /* Create a frame. */ + asm ("ldo 64(%sp),%sp"); + asm (".cfi_def_cfa_offset -64"); + /* Save the current machine context to oucp. */ - __getcontext (oucp); + asm ("bl __getcontext,%rp"); + + /* Copy oucp to register ret1 (r29). __getcontext saves and restores it + on a normal return. It is restored from oR29 on reactivation. */ + asm ("copy %r26,%ret1"); + + /* Pop frame. */ + asm ("ldo -64(%sp),%sp"); + asm (".cfi_def_cfa_offset 0"); + + /* Load return pointer from oR28. */ + asm ("ldw %0(%%ret1),%%rp" : : "i" (oR28)); + + /* Return if error. */ + asm ("or,= %r0,%ret0,%r0"); + asm ("bv,n %r0(%rp)"); + + /* Load sc_sar flag. */ + asm ("ldb %0(%%ret1),%%r20" : : "i" (oSAR)); + + /* Return if oucp context has been reactivated. */ + asm ("or,= %r0,%r20,%r0"); + asm ("bv,n %r0(%rp)"); + + /* Mark sc_sar flag. */ + asm ("1: ldi 1,%r20"); + asm ("stb %%r20,%0(%%ret1)" : : "i" (oSAR)); + + /* Activate the machine context in ucp. */ + asm ("bl __setcontext,%rp"); + asm ("ldw %0(%%ret1),%%r26" : : "i" (oR25)); - /* mark sc_sar flag to skip the setcontext call on reactivation. */ - if (oucp->uc_mcontext.sc_sar == 0) { - oucp->uc_mcontext.sc_sar++; + /* Load return pointer. */ + asm ("ldw %0(%%ret1),%%rp" : : "i" (oR28)); - /* Restore the machine context in ucp. */ - __setcontext (ucp); - } + /* A successful call to setcontext does not return. */ + asm ("bv,n %r0(%rp)"); + /* Make gcc happy. */ return 0; } diff --git a/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c b/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c index 0ff1a214e6..2b1feb4766 100644 --- a/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c +++ b/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c @@ -22,6 +22,7 @@ #include <support/xsocket.h> #include <support/xunistd.h> #include <stdbool.h> +#include <socket-constants-time64.h> /* AF_INET socket and address used to receive data. */ static int srv; @@ -88,7 +89,7 @@ do_test_large_buffer (bool mc) /* Enable 32 bit timeval precision and check if no 64 bit timeval stamp is created. */ { - int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMP_OLD, &(int){1}, + int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMP_OLD, &(int){1}, sizeof (int)); TEST_VERIFY_EXIT (r != -1); @@ -103,10 +104,10 @@ do_test_large_buffer (bool mc) if (cmsg->cmsg_level != SOL_SOCKET) continue; - if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMP_NEW) + if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMP_NEW) found_timestamp = true; else - TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMP_NEW); + TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMP_NEW); } TEST_COMPARE (found_timestamp, sizeof (time_t) > 4); @@ -114,7 +115,7 @@ do_test_large_buffer (bool mc) /* Same as before, but for timespec. */ { - int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMPNS_OLD, &(int){1}, + int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMPNS_OLD, &(int){1}, sizeof (int)); TEST_VERIFY_EXIT (r != -1); @@ -129,10 +130,10 @@ do_test_large_buffer (bool mc) if (cmsg->cmsg_level != SOL_SOCKET) continue; - if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMPNS_NEW) + if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMPNS_NEW) found_timestamp = true; else - TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMPNS_NEW); + TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMPNS_NEW); } TEST_COMPARE (found_timestamp, sizeof (time_t) > 4); @@ -151,7 +152,7 @@ do_test_small_buffer (bool mc) /* Enable 32 bit timeval precision and check if no 64 bit timeval stamp is created. */ { - int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMP_OLD, &(int){1}, + int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMP_OLD, &(int){1}, sizeof (int)); TEST_VERIFY_EXIT (r != -1); @@ -172,10 +173,10 @@ do_test_small_buffer (bool mc) if (cmsg->cmsg_level != SOL_SOCKET) continue; - if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMP_NEW) + if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMP_NEW) found_timestamp = true; else - TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMP_NEW); + TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMP_NEW); } if (sizeof (time_t) > 4) @@ -192,7 +193,7 @@ do_test_small_buffer (bool mc) /* Same as before, but for timespec. */ { - int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMPNS_OLD, &(int){1}, + int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMPNS_OLD, &(int){1}, sizeof (int)); TEST_VERIFY_EXIT (r != -1); @@ -213,10 +214,10 @@ do_test_small_buffer (bool mc) if (cmsg->cmsg_level != SOL_SOCKET) continue; - if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMPNS_NEW) + if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMPNS_NEW) found_timestamp = true; else - TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMPNS_NEW); + TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMPNS_NEW); } if (sizeof (time_t) > 4) diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index 6cf708335c..c6bee981f8 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -99,7 +99,9 @@ tests += \ tst-strcpy-rtm \ tst-strlen-rtm \ tst-strncmp-rtm \ - tst-strrchr-rtm + tst-strrchr-rtm \ + tst-wcsncmp-rtm \ +# tests CFLAGS-tst-memchr-rtm.c += -mrtm CFLAGS-tst-memcmp-rtm.c += -mrtm @@ -109,8 +111,9 @@ CFLAGS-tst-memset-rtm.c += -mrtm CFLAGS-tst-strchr-rtm.c += -mrtm CFLAGS-tst-strcpy-rtm.c += -mrtm CFLAGS-tst-strlen-rtm.c += -mrtm -CFLAGS-tst-strncmp-rtm.c += -mrtm +CFLAGS-tst-strncmp-rtm.c += -mrtm -Wno-error CFLAGS-tst-strrchr-rtm.c += -mrtm +CFLAGS-tst-wcsncmp-rtm.c += -mrtm -Wno-error endif ifneq ($(enable-cet),no) diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c index 09ed6fa0d6..300bc8c281 100644 --- a/sysdeps/x86/tst-strncmp-rtm.c +++ b/sysdeps/x86/tst-strncmp-rtm.c @@ -16,20 +16,35 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#include <stdint.h> #include <tst-string-rtm.h> +#ifdef WIDE +# define CHAR wchar_t +# define MEMSET wmemset +# define STRNCMP wcsncmp +# define TEST_NAME "wcsncmp" +#else /* !WIDE */ +# define CHAR char +# define MEMSET memset +# define STRNCMP strncmp +# define TEST_NAME "strncmp" +#endif /* !WIDE */ + + + #define LOOP 3000 #define STRING_SIZE 1024 -char string1[STRING_SIZE]; -char string2[STRING_SIZE]; +CHAR string1[STRING_SIZE]; +CHAR string2[STRING_SIZE]; __attribute__ ((noinline, noclone)) static int prepare (void) { - memset (string1, 'a', STRING_SIZE - 1); - memset (string2, 'a', STRING_SIZE - 1); - if (strncmp (string1, string2, STRING_SIZE) == 0) + MEMSET (string1, 'a', STRING_SIZE - 1); + MEMSET (string2, 'a', STRING_SIZE - 1); + if (STRNCMP (string1, string2, STRING_SIZE) == 0) return EXIT_SUCCESS; else return EXIT_FAILURE; @@ -39,7 +54,17 @@ __attribute__ ((noinline, noclone)) static int function (void) { - if (strncmp (string1, string2, STRING_SIZE) == 0) + if (STRNCMP (string1, string2, STRING_SIZE) == 0) + return 0; + else + return 1; +} + +__attribute__ ((noinline, noclone)) +static int +function_overflow (void) +{ + if (STRNCMP (string1, string2, SIZE_MAX) == 0) return 0; else return 1; @@ -48,5 +73,9 @@ function (void) static int do_test (void) { - return do_test_1 ("strncmp", LOOP, prepare, function); + int status = do_test_1 (TEST_NAME, LOOP, prepare, function); + if (status != EXIT_SUCCESS) + return status; + status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow); + return status; } diff --git a/sysdeps/x86/tst-wcsncmp-rtm.c b/sysdeps/x86/tst-wcsncmp-rtm.c new file mode 100644 index 0000000000..bad3b86378 --- /dev/null +++ b/sysdeps/x86/tst-wcsncmp-rtm.c @@ -0,0 +1,21 @@ +/* Test case for wcsncmp inside a transactionally executing RTM region. + Copyright (C) 2022 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 + <https://www.gnu.org/licenses/>. */ + +#define WIDE 1 +#include <wchar.h> +#include "tst-strncmp-rtm.c" diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S index 9c73b5899d..cdcb3c5a26 100644 --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S @@ -95,7 +95,7 @@ ENTRY (STRCMP) length to bound a valid memory region. In these cases just use 'wcscmp'. */ shrq $56, %rcx - jnz __wcscmp_avx2 + jnz OVERFLOW_STRCMP # endif /* Convert units: from wide to byte char. */ shl $2, %RDX_LP diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S index 37d1224bb9..68bad365ba 100644 --- a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S +++ b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S @@ -1,3 +1,4 @@ #define STRCMP __strncmp_avx2_rtm #define USE_AS_STRNCMP 1 +#define OVERFLOW_STRCMP __strcmp_avx2_rtm #include "strcmp-avx2-rtm.S" diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2.S b/sysdeps/x86_64/multiarch/strncmp-avx2.S index 1678bcc235..f138e9f1fd 100644 --- a/sysdeps/x86_64/multiarch/strncmp-avx2.S +++ b/sysdeps/x86_64/multiarch/strncmp-avx2.S @@ -1,3 +1,4 @@ #define STRCMP __strncmp_avx2 #define USE_AS_STRNCMP 1 +#define OVERFLOW_STRCMP __strcmp_avx2 #include "strcmp-avx2.S" diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S index 4e88c70cc6..f467582cbe 100644 --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S @@ -1,5 +1,5 @@ #define STRCMP __wcsncmp_avx2_rtm #define USE_AS_STRNCMP 1 #define USE_AS_WCSCMP 1 - +#define OVERFLOW_STRCMP __wcscmp_avx2_rtm #include "strcmp-avx2-rtm.S" diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S index 4fa1de4d3f..e9ede522b8 100644 --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S @@ -1,5 +1,5 @@ #define STRCMP __wcsncmp_avx2 #define USE_AS_STRNCMP 1 #define USE_AS_WCSCMP 1 - +#define OVERFLOW_STRCMP __wcscmp_avx2 #include "strcmp-avx2.S"
Close