diff --git a/backport-df-fix-duplicated-remote-entries-due-to-bind-mounts.patch b/backport-df-fix-duplicated-remote-entries-due-to-bind-mounts.patch new file mode 100644 index 0000000000000000000000000000000000000000..66ffdb585edc0cff9f1330a26f627b1c96647186 --- /dev/null +++ b/backport-df-fix-duplicated-remote-entries-due-to-bind-mounts.patch @@ -0,0 +1,89 @@ +From d6125af095c9553f38cba0696f15158f5abe4ecc Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Wed, 30 Jun 2021 17:53:22 +0200 +Subject: [PATCH] df: fix duplicated remote entries due to bind mounts + +As originally reported in , +df invoked without -a printed duplicated entries for NFS mounts +of bind mounts. This is a regression from commit v8.25-54-g1c17f61ef99, +which introduced the use of a hash table. + +The proposed patch makes sure that the devlist entry seen the last time +is used for comparison when eliminating duplicated mount entries. This +way it worked before introducing the hash table. + +Patch co-authored by Roberto Bergantinos. + +* src/ls.c (struct devlist): Introduce the seen_last pointer. +(devlist_for_dev): Return the devlist entry seen the last time if found. +(filter_mount_list): Remember the devlist entry seen the last time for +each hashed item. +* NEWS: Mention the bug fix. +Fixes https://bugs.gnu.org/49298 + +Reference: https://github.com/coreutils/coreutils/commit/d6125af095c9553f38cba0696f15158f5abe4ecc +Conflict: NEWS Context adaptation + +--- + NEWS | 3 +++ + src/df.c | 15 +++++++++++++-- + 2 files changed, 16 insertions(+), 2 deletions(-) + +diff --git a/NEWS b/NEWS +index fc8ff16..bae6ced 100644 +--- a/NEWS ++++ b/NEWS +@@ -4,6 +4,9 @@ GNU coreutils NEWS -*- outline -*- + + ** Bug fixes + ++ df no longer outputs duplicate remote mounts in the presence of bind mounts. ++ [bug introduced in coreutils-8.26] ++ + 'sort -g' no longer infloops when given multiple NaNs on platforms + like x86-64 where 'long double' has padding bits in memory. + Although the fix alters sort -g's NaN ordering, that ordering has +diff --git a/src/df.c b/src/df.c +index 7e01839..3e9247f 100644 +--- a/src/df.c ++++ b/src/df.c +@@ -54,6 +54,7 @@ struct devlist + dev_t dev_num; + struct mount_entry *me; + struct devlist *next; ++ struct devlist *seen_last; /* valid for hashed devlist entries only */ + }; + + /* Filled with device numbers of examined file systems to avoid +@@ -689,7 +690,13 @@ devlist_for_dev (dev_t dev) + return NULL; + struct devlist dev_entry; + dev_entry.dev_num = dev; +- return hash_lookup (devlist_table, &dev_entry); ++ ++ struct devlist *found = hash_lookup (devlist_table, &dev_entry); ++ if (found == NULL) ++ return NULL; ++ ++ /* Return the last devlist entry we have seen with this dev_num */ ++ return found->seen_last; + } + + static void +@@ -807,8 +814,12 @@ filter_mount_list (bool devices_only) + devlist->dev_num = buf.st_dev; + devlist->next = device_list; + device_list = devlist; +- if (hash_insert (devlist_table, devlist) == NULL) ++ ++ struct devlist *hash_entry = hash_insert (devlist_table, devlist); ++ if (hash_entry == NULL) + xalloc_die (); ++ /* Ensure lookups use this latest devlist. */ ++ hash_entry->seen_last = devlist; + + me = me->me_next; + } +-- +2.27.0 + diff --git a/backport-df-fix-memory-leak.patch b/backport-df-fix-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..c734311dd6fed6eacdfec4cb94af1bfccc51b124 --- /dev/null +++ b/backport-df-fix-memory-leak.patch @@ -0,0 +1,57 @@ +From fb7579768d688a300c4ac76451e1fc7cad59e3e8 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Mon, 31 Jan 2022 19:52:43 -0800 +Subject: [PATCH] df: fix memory leak + +* src/df.c (devlist_free): Remove. +(filter_mount_list): Free all of devlist, instead of merely +the entries in devlist_table. + +Reference: https://github.com/coreutils/coreutils/commit/fb7579768d688a300c4ac76451e1fc7cad59e3e8 +Conflict: NA +--- + src/df.c | 14 ++++---------- + 1 file changed, 4 insertions(+), 10 deletions(-) + +diff --git a/src/df.c b/src/df.c +index 7d3207807..4b2cfb77a 100644 +--- a/src/df.c ++++ b/src/df.c +@@ -710,12 +710,6 @@ devlist_for_dev (dev_t dev) + return found->seen_last; + } + +-static void +-devlist_free (void *p) +-{ +- free (p); +-} +- + /* Filter mount list by skipping duplicate entries. + In the case of duplicates - based on the device number - the mount entry + with a '/' in its me_devname (i.e., not pseudo name like tmpfs) wins. +@@ -736,9 +730,7 @@ filter_mount_list (bool devices_only) + mount_list_size++; + + devlist_table = hash_initialize (mount_list_size, NULL, +- devlist_hash, +- devlist_compare, +- devlist_free); ++ devlist_hash, devlist_compare, NULL); + if (devlist_table == NULL) + xalloc_die (); + +@@ -845,7 +837,9 @@ filter_mount_list (bool devices_only) + me = device_list->me; + me->me_next = mount_list; + mount_list = me; +- device_list = device_list->next; ++ struct devlist *next = device_list->next; ++ free (device_list); ++ device_list = next; + } + + hash_free (devlist_table); +-- +2.27.0 + diff --git a/backport-ls-avoid-triggering-automounts.patch b/backport-ls-avoid-triggering-automounts.patch new file mode 100644 index 0000000000000000000000000000000000000000..80c86ebd87abda720ec58bdb4a7f38c99210f649 --- /dev/null +++ b/backport-ls-avoid-triggering-automounts.patch @@ -0,0 +1,54 @@ +From 85c975df2c25bd799370b04bb294e568e001102f Mon Sep 17 00:00:00 2001 +From: Rohan Sable +Date: Mon, 7 Mar 2022 14:14:13 +0000 +Subject: [PATCH] ls: avoid triggering automounts + +statx() has different defaults wrt automounting +compared to stat() or lstat(), so explicitly +set the AT_NO_AUTOMOUNT flag to suppress that behavior, +and avoid unintended operations or potential errors. + +* src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior. +* NEWS: Mention the change in behavior. +Fixes https://bugs.gnu.org/54286 + +Signed-off-by: Rohan Sable + +Reference: https://github.com/coreutils/coreutils/commit/85c975df2c25bd799370b04bb294e568e001102f +Conflict: NEWS Context adaptation + +--- + NEWS | 3 +++ + src/ls.c | 2 +- + 2 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/NEWS b/NEWS +index bae6ced..76a6986 100644 +--- a/NEWS ++++ b/NEWS +@@ -4,6 +4,9 @@ GNU coreutils NEWS -*- outline -*- + + ** Bug fixes + ++ ls no longer tries to automount files, reverting to the behavior ++ before the statx() call was introduced in coreutils-8.32. ++ + df no longer outputs duplicate remote mounts in the presence of bind mounts. + [bug introduced in coreutils-8.26] + +diff --git a/src/ls.c b/src/ls.c +index 8eb483d..cd23446 100644 +--- a/src/ls.c ++++ b/src/ls.c +@@ -1154,7 +1154,7 @@ do_statx (int fd, const char *name, struct stat *st, int flags, + { + struct statx stx; + bool want_btime = mask & STATX_BTIME; +- int ret = statx (fd, name, flags, mask, &stx); ++ int ret = statx (fd, name, flags | AT_NO_AUTOMOUNT, mask, &stx); + if (ret >= 0) + { + statx_to_stat (&stx, st); +-- +2.27.0 + diff --git a/backport-pr-don-t-use-uninitialized-var.patch b/backport-pr-don-t-use-uninitialized-var.patch new file mode 100644 index 0000000000000000000000000000000000000000..a7edf8f64d647dd6c8fdebe2e616b90ebadc84a6 --- /dev/null +++ b/backport-pr-don-t-use-uninitialized-var.patch @@ -0,0 +1,50 @@ +From 81d58df1647ea79c5161f99d8bd241f0c78df729 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Tue, 19 Apr 2022 16:13:55 -0700 +Subject: [PATCH] =?UTF-8?q?pr:=20don=E2=80=99t=20use=20uninitialized=20var?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Found with -flto and --enable-gcc-warnings. +* src/pr.c (getoptarg): Fix misuse of xstrtol, which does not +necessarily set tmp_long on errror, and does not set errno in any +reliable way. The previous code might access uninitialized +storage; on typical platforms this merely causes it to possibly +print the wrong diagnostic. + +Reference: https://github.com/coreutils/coreutils/commit/81d58df1647ea79c5161f99d8bd241f0c78df729 +Conflict: NA + +--- + src/pr.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/src/pr.c b/src/pr.c +index 4c17c0050..a8feba9d8 100644 +--- a/src/pr.c ++++ b/src/pr.c +@@ -1173,10 +1173,17 @@ getoptarg (char *arg, char switch_char, char *character, int *number) + if (*arg) + { + long int tmp_long; +- if (xstrtol (arg, NULL, 10, &tmp_long, "") != LONGINT_OK +- || tmp_long <= 0 || INT_MAX < tmp_long) ++ strtol_error e = xstrtol (arg, NULL, 10, &tmp_long, ""); ++ if (e == LONGINT_OK) + { +- error (0, INT_MAX < tmp_long ? EOVERFLOW : errno, ++ if (tmp_long <= 0) ++ e = LONGINT_INVALID; ++ else if (INT_MAX < tmp_long) ++ e = LONGINT_OVERFLOW; ++ } ++ if (e != LONGINT_OK) ++ { ++ error (0, e & LONGINT_OVERFLOW ? EOVERFLOW : 0, + _("'-%c' extra characters or invalid number in the argument: %s"), + switch_char, quote (arg)); + usage (EXIT_FAILURE); +-- +2.27.0 + diff --git a/backport-sort-fix-sort-g-infloop-again.patch b/backport-sort-fix-sort-g-infloop-again.patch new file mode 100644 index 0000000000000000000000000000000000000000..d8cb34e33a0eb778cd0c93fc022b709db90e40fa --- /dev/null +++ b/backport-sort-fix-sort-g-infloop-again.patch @@ -0,0 +1,79 @@ +From 2f56f5a42033dc6db15d8963e54566f01fa0d61d Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Sun, 1 May 2022 22:46:21 -0700 +Subject: [PATCH] sort: fix sort -g infloop again + +Problem reported by Giulio Genovese (Bug#55212). +* src/sort.c (nan_compare): To compare NaNs, simply printf+strcmp. +This avoids the problem of padding bits and unspecified behavior. +Args are now long double instead of char *; caller changed. + +Reference:https://github.com/coreutils/coreutils/commit/2f56f5a42033dc6db15d8963e54566f01fa0d61d +Conflict: NEWS Context adaptation + +--- + NEWS | 6 ++++++ + src/sort.c | 21 ++++++--------------- + 2 files changed, 12 insertions(+), 15 deletions(-) + +diff --git a/NEWS b/NEWS +index 3e44c0c..fc8ff16 100644 +--- a/NEWS ++++ b/NEWS +@@ -4,6 +4,12 @@ GNU coreutils NEWS -*- outline -*- + + ** Bug fixes + ++ 'sort -g' no longer infloops when given multiple NaNs on platforms ++ like x86-64 where 'long double' has padding bits in memory. ++ Although the fix alters sort -g's NaN ordering, that ordering has ++ long been documented to be platform-dependent. ++ [bug introduced 1999-05-02 and only partly fixed in coreutils-8.14] ++ + cp now copies /dev/fd/N correctly on platforms like Solaris where + it is a character-special file whose minor device number is N. + [bug introduced in fileutils-4.1.6] +diff --git a/src/sort.c b/src/sort.c +index 8e1533e..5b4342f 100644 +--- a/src/sort.c ++++ b/src/sort.c +@@ -2360,22 +2360,13 @@ numcompare_mb (const char *a, const char *b) + } + #endif /* HAV_EMBRTOWC */ + +-/* Work around a problem whereby the long double value returned by glibc's +- strtold ("NaN", ...) contains uninitialized bits: clear all bytes of +- A and B before calling strtold. FIXME: remove this function if +- gnulib guarantees that strtold's result is always well defined. */ + static int +-nan_compare (char const *sa, char const *sb) ++nan_compare (long double a, long double b) + { +- long double a; +- memset (&a, 0, sizeof a); +- a = strtold (sa, NULL); +- +- long double b; +- memset (&b, 0, sizeof b); +- b = strtold (sb, NULL); +- +- return memcmp (&a, &b, sizeof a); ++ char buf[2][sizeof "-nan()" + CHAR_BIT * sizeof a]; ++ snprintf (buf[0], sizeof buf[0], "%Lf", a); ++ snprintf (buf[1], sizeof buf[1], "%Lf", b); ++ return strcmp (buf[0], buf[1]); + } + + static int +@@ -2403,7 +2394,7 @@ general_numcompare (char const *sa, char const *sb) + : a == b ? 0 + : b == b ? -1 + : a == a ? 1 +- : nan_compare (sa, sb)); ++ : nan_compare (a, b)); + } + + /* Return an integer in 1..12 of the month name MONTH. +-- +2.27.0 + diff --git a/backport-stat-only-automount-with-cached-never.patch b/backport-stat-only-automount-with-cached-never.patch new file mode 100644 index 0000000000000000000000000000000000000000..9baf4ec324b6b9874be4cf2aa0ebd4adbf7e5c03 --- /dev/null +++ b/backport-stat-only-automount-with-cached-never.patch @@ -0,0 +1,67 @@ +From 92cb8427c537f37edd43c5cef1909585201372ab Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Mon, 7 Mar 2022 23:29:20 +0000 +Subject: [PATCH] stat: only automount with --cached=never + +Revert to the default behavior before the introduction of statx(). + +* src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never. +* doc/coreutils.texi (stat invocation): Mention the automount +behavior with --cached=never. +* NEWS: Mention the change in behavior. + +Fixes https://bugs.gnu.org/54287 + +Reference: https://github.com/coreutils/coreutils/commit/92cb8427c537f37edd43c5cef1909585201372ab +Conflict: NEWS Context adaptation + +--- + NEWS | 4 ++++ + doc/coreutils.texi | 1 + + src/stat.c | 3 +++ + 3 files changed, 8 insertions(+) + +diff --git a/NEWS b/NEWS +index 76a6986..81f5cf5 100644 +--- a/NEWS ++++ b/NEWS +@@ -4,6 +4,10 @@ GNU coreutils NEWS -*- outline -*- + + ** Bug fixes + ++ stat no longer tries to automount files by default, reverting to the ++ behavior before the statx() call was introduced in coreutils-8.32. ++ Only `stat --cached=never` will continue to automount files. ++ + ls no longer tries to automount files, reverting to the behavior + before the statx() call was introduced in coreutils-8.32. + +diff --git a/doc/coreutils.texi b/doc/coreutils.texi +index 467f635..ff8e7a6 100644 +--- a/doc/coreutils.texi ++++ b/doc/coreutils.texi +@@ -12382,6 +12382,7 @@ Always read the already cached attributes if available. + + @item never + Always sychronize with the latest file system attributes. ++This also mounts automounted files. + + @item default + Leave the caching behavior to the underlying file system. +diff --git a/src/stat.c b/src/stat.c +index 5012622..1f1c8e4 100644 +--- a/src/stat.c ++++ b/src/stat.c +@@ -1355,6 +1355,9 @@ do_stat (char const *filename, char const *format, char const *format2) + else if (force_sync) + flags |= AT_STATX_FORCE_SYNC; + ++ if (! force_sync) ++ flags |= AT_NO_AUTOMOUNT; ++ + fd = statx (fd, pathname, flags, format_to_mask (format), &stx); + if (fd < 0) + { +-- +2.27.0 + diff --git a/backport-tests-sort-NaN-infloop-augment-testing-for-recent-fi.patch b/backport-tests-sort-NaN-infloop-augment-testing-for-recent-fi.patch new file mode 100644 index 0000000000000000000000000000000000000000..7356d0126a61f4d502fe390784ab23bc7e8ae8ae --- /dev/null +++ b/backport-tests-sort-NaN-infloop-augment-testing-for-recent-fi.patch @@ -0,0 +1,47 @@ +From ddafdae21c574b1dcd5c56e403c82010e7ed3565 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Mon, 2 May 2022 14:27:34 +0100 +Subject: [PATCH] tests: sort-NaN-infloop: augment testing for recent fix + +* tests/misc/sort-NaN-infloop.sh: Add test case from +https://unix.stackexchange.com/a/700967/37127 +* src/sort.c: Avoid syntax-check failure. + +Reference: https://github.com/coreutils/coreutils/commit/ddafdae21c574b1dcd5c56e403c82010e7ed3565 +Conflict: NA + +--- + src/sort.c | 2 +- + tests/misc/sort-NaN-infloop.sh | 3 +++ + 2 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/sort.c b/src/sort.c +index b2a465cf5..8af356c66 100644 +--- a/src/sort.c ++++ b/src/sort.c +@@ -2006,7 +2006,7 @@ numcompare (char const *a, char const *b) + static int + nan_compare (long double a, long double b) + { +- char buf[2][sizeof "-nan()" + CHAR_BIT * sizeof a]; ++ char buf[2][sizeof "-nan""()" + CHAR_BIT * sizeof a]; + snprintf (buf[0], sizeof buf[0], "%Lf", a); + snprintf (buf[1], sizeof buf[1], "%Lf", b); + return strcmp (buf[0], buf[1]); +diff --git a/tests/misc/sort-NaN-infloop.sh b/tests/misc/sort-NaN-infloop.sh +index 93cf9bd77..cc1c583cd 100755 +--- a/tests/misc/sort-NaN-infloop.sh ++++ b/tests/misc/sort-NaN-infloop.sh +@@ -23,6 +23,9 @@ echo nan > F || framework_failure_ + printf 'nan\nnan\n' > exp || framework_failure_ + timeout 10 sort -g -m F F > out || fail=1 + ++# This was seen to infloop on some systems until coreutils v9.2 (bug 55212) ++yes nan | head -n128095 | timeout 60 sort -g > /dev/null || fail=1 ++ + compare exp out || fail=1 + + Exit $fail +-- +2.27.0 + diff --git a/backport-touch-fix-aliasing-bug.patch b/backport-touch-fix-aliasing-bug.patch new file mode 100644 index 0000000000000000000000000000000000000000..224d2fa680c8d6f740951ea6b3942a4c0f7842f5 --- /dev/null +++ b/backport-touch-fix-aliasing-bug.patch @@ -0,0 +1,79 @@ +From afffa445b968d2fa4397bcf1e93f3dde28689526 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Wed, 27 Jul 2022 09:59:38 -0700 +Subject: [PATCH] touch: fix aliasing bug + +Problem reported by Tim Lange in: +https://lists.gnu.org/r/coreutils/2022-07/msg00008.html +* src/touch.c (date_relative): Rename from get_reldate, +and use a functional style to fix the aliasing bug. + +Reference:https://github.com/coreutils/coreutils/commit/afffa445b968d2fa4397bcf1e93f3dde28689526 +Conflict:NA + +--- + src/touch.c | 24 +++++++++++------------- + 1 file changed, 11 insertions(+), 13 deletions(-) + +diff --git a/src/touch.c b/src/touch.c +index 21c247d0b..d8d232c19 100644 +--- a/src/touch.c ++++ b/src/touch.c +@@ -105,15 +105,15 @@ static int const time_masks[] = + CH_ATIME, CH_ATIME, CH_ATIME, CH_MTIME, CH_MTIME + }; + +-/* Store into *RESULT the result of interpreting FLEX_DATE as a date, +- relative to NOW. If NOW is null, use the current time. */ ++/* The interpretation of FLEX_DATE as a date, relative to NOW. */ + +-static void +-get_reldate (struct timespec *result, +- char const *flex_date, struct timespec const *now) ++static struct timespec ++date_relative (char const *flex_date, struct timespec now) + { +- if (! parse_datetime (result, flex_date, now)) ++ struct timespec result; ++ if (! parse_datetime (&result, flex_date, &now)) + die (EXIT_FAILURE, 0, _("invalid date format %s"), quote (flex_date)); ++ return result; + } + + /* Update the time of file FILE according to the options given. +@@ -356,19 +356,17 @@ main (int argc, char **argv) + if (flex_date) + { + if (change_times & CH_ATIME) +- get_reldate (&newtime[0], flex_date, &newtime[0]); ++ newtime[0] = date_relative (flex_date, newtime[0]); + if (change_times & CH_MTIME) +- get_reldate (&newtime[1], flex_date, &newtime[1]); ++ newtime[1] = date_relative (flex_date, newtime[1]); + } + } + else + { + if (flex_date) + { +- struct timespec now; +- gettime (&now); +- get_reldate (&newtime[0], flex_date, &now); +- newtime[1] = newtime[0]; ++ struct timespec now = current_timespec (); ++ newtime[1] = newtime[0] = date_relative (flex_date, now); + date_set = true; + + /* If neither -a nor -m is specified, treat "-d now" as if +@@ -383,7 +381,7 @@ main (int argc, char **argv) + struct timespec notnow, notnow1; + notnow.tv_sec = now.tv_sec ^ 1; + notnow.tv_nsec = now.tv_nsec; +- get_reldate (¬now1, flex_date, ¬now); ++ notnow1 = date_relative (flex_date, notnow); + if (notnow1.tv_sec == notnow.tv_sec + && notnow1.tv_nsec == notnow.tv_nsec) + date_set = false; +-- +2.27.0 + diff --git a/coreutils.spec b/coreutils.spec index 32716efdc067213e8aad2dc375f31e45ca81a266..94a15e3db4d3e394ca07c88741ae061d5d812707 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils Version: 8.32 -Release: 4 +Release: 5 License: GPLv3+ Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ @@ -29,6 +29,14 @@ Patch11: backport-ls-fix-crash-printing-SELinux-context-for-unstatable.patch Patch12: backport-tr-fix-crash-validating-c-with-some-case-char-classe.patch Patch13: backport-timeout-ensure-foreground-k-exits-with-status-137.patch Patch14: backport-config-color-alias-for-ls.patch +Patch15: backport-pr-don-t-use-uninitialized-var.patch +Patch16: backport-sort-fix-sort-g-infloop-again.patch +Patch17: backport-tests-sort-NaN-infloop-augment-testing-for-recent-fi.patch +Patch18: backport-touch-fix-aliasing-bug.patch +Patch19: backport-df-fix-duplicated-remote-entries-due-to-bind-mounts.patch +Patch20: backport-df-fix-memory-leak.patch +Patch21: backport-ls-avoid-triggering-automounts.patch +Patch22: backport-stat-only-automount-with-cached-never.patch Conflicts: filesystem < 3 # To avoid clobbering installs @@ -147,6 +155,9 @@ fi %{_mandir}/man*/* %changelog +* Fri Oct 21 2022 jiangchuangang - 8.32-5 +- backport some patches from upstream + * Wed Aug 31 2022 hongjinghao - 8.32-4 - Auto display color difference when use ls