From faf02d487fbbb360129b5800812bd74c856a3644 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Thu, 18 Feb 2021 15:38:36 +0100 Subject: [PATCH 1/4] Resolves: #1921427 - stat: add support for the exfat file system --- coreutils-8.32-stat-exfat.patch | 32 ++++++++++++++++++++++++++++++++ coreutils.spec | 8 +++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 coreutils-8.32-stat-exfat.patch diff --git a/coreutils-8.32-stat-exfat.patch b/coreutils-8.32-stat-exfat.patch new file mode 100644 index 0000000..ea8d0cd --- /dev/null +++ b/coreutils-8.32-stat-exfat.patch @@ -0,0 +1,32 @@ +From b87f944c87ffe04db6e5476b007a8e4979de933d Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Thu, 18 Feb 2021 11:18:04 +0100 +Subject: [PATCH] stat,tail: add support for the exfat file system + +Bug: https://bugzilla.redhat.com/1921427 + +* src/stat.c (human_fstype): Add case for the 'exfat' file system type. +Fixes https://bugs.gnu.org/46613 + +Upstream-commit: a5e0d8f387e81e854427addbbaf2504541bbf4b9 +Signed-off-by: Kamil Dudka +--- + src/stat.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/stat.c b/src/stat.c +index 8cd69da..4e1c8e3 100644 +--- a/src/stat.c ++++ b/src/stat.c +@@ -361,6 +361,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) + return "efs"; + case S_MAGIC_EROFS_V1: /* 0xE0F5E1E2 local */ + return "erofs"; ++ case S_MAGIC_EXFAT: /* 0x2011BAB0 local */ ++ return "exfat"; + case S_MAGIC_EXFS: /* 0x45584653 local */ + return "exfs"; + case S_MAGIC_EXOFS: /* 0x5DF5 local */ +-- +2.26.2 + diff --git a/coreutils.spec b/coreutils.spec index 829fab4..b400a95 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 8.32 -Release: 17%{?dist} +Release: 18%{?dist} License: GPLv3+ Url: https://www.gnu.org/software/coreutils/ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz @@ -40,6 +40,9 @@ Patch8: coreutils-8.32-split-number.patch # ls: fix crash printing SELinux context for unstatable files (#1921249) Patch9: coreutils-8.32-ls-scontext-crash.patch +# stat: add support for the exfat file system (#1921427) +Patch10: coreutils-8.32-stat-exfat.patch + # disable the test-lock gnulib test prone to deadlock Patch100: coreutils-8.26-test-lock.patch @@ -293,6 +296,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Thu Feb 18 2021 Kamil Dudka - 8.32-18 +- stat: add support for the exfat file system (#1921427) + * Tue Feb 02 2021 Kamil Dudka - 8.32-17 - ls: fix crash printing SELinux context for unstatable files (#1921249) - split: fix --number=K/N to output correct part of file (#1921246) From 2373b34bacc1676fafe5dcaeabb92e04ec77d0f1 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Tue, 8 Jun 2021 09:16:40 +0200 Subject: [PATCH 2/4] Resolves: #1913358 - mountlist: recognize fuse.portal as dummy file system --- coreutils-8.32-fuse-portal.patch | 38 ++++++++++++++++++++++++++++++++ coreutils.spec | 8 ++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 coreutils-8.32-fuse-portal.patch diff --git a/coreutils-8.32-fuse-portal.patch b/coreutils-8.32-fuse-portal.patch new file mode 100644 index 0000000..54b7975 --- /dev/null +++ b/coreutils-8.32-fuse-portal.patch @@ -0,0 +1,38 @@ +From 602fb566468d3837b7871c17a0fab1a20228d119 Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Mon, 7 Jun 2021 14:43:03 +0200 +Subject: [PATCH] mountlist: recognize fuse.portal as dummy file system + +This was originally proposed at: + + https://lists.gnu.org/archive/html/bug-gnulib/2021-02/msg00053.html + +As the full review might take some time, would it be possible to apply +at least the part related to fuse.portal file systems? They started to +cause problems recently: + + https://bugs.launchpad.net/ubuntu/+source/xdg-desktop-portal/+bug/1905623 + https://github.com/muesli/duf/issues/35 + https://bugzilla.redhat.com/1913358 + +Upstream-commit: 9a38d499ca16f2f4304992eb1ab0894cd0b478e1 +Signed-off-by: Kamil Dudka +--- + lib/mountlist.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/mountlist.c b/lib/mountlist.c +index e0227b7..e5f6b07 100644 +--- a/lib/mountlist.c ++++ b/lib/mountlist.c +@@ -170,6 +170,7 @@ + || strcmp (Fs_type, "debugfs") == 0 \ + || strcmp (Fs_type, "devpts") == 0 \ + || strcmp (Fs_type, "fusectl") == 0 \ ++ || strcmp (Fs_type, "fuse.portal") == 0 \ + || strcmp (Fs_type, "mqueue") == 0 \ + || strcmp (Fs_type, "rpc_pipefs") == 0 \ + || strcmp (Fs_type, "sysfs") == 0 \ +-- +2.31.1 + diff --git a/coreutils.spec b/coreutils.spec index b400a95..95613b2 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 8.32 -Release: 18%{?dist} +Release: 19%{?dist} License: GPLv3+ Url: https://www.gnu.org/software/coreutils/ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz @@ -43,6 +43,9 @@ Patch9: coreutils-8.32-ls-scontext-crash.patch # stat: add support for the exfat file system (#1921427) Patch10: coreutils-8.32-stat-exfat.patch +# mountlist: recognize fuse.portal as dummy file system (#1913358) +Patch15: coreutils-8.32-fuse-portal.patch + # disable the test-lock gnulib test prone to deadlock Patch100: coreutils-8.26-test-lock.patch @@ -296,6 +299,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Tue Jun 08 2021 Kamil Dudka - 8.32-19 +- mountlist: recognize fuse.portal as dummy file system (#1913358) + * Thu Feb 18 2021 Kamil Dudka - 8.32-18 - stat: add support for the exfat file system (#1921427) From eeff04430c49f8159559b52b3dbe6acc0ff484ff Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Thu, 1 Jul 2021 14:42:14 +0200 Subject: [PATCH 3/4] Resolves: #1976935 - tail: fix stack out-of-bounds write with --follow --- coreutils-8.32-tail-use-poll.patch | 181 +++++++++++++++++++++++++++++ coreutils.spec | 8 +- 2 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 coreutils-8.32-tail-use-poll.patch diff --git a/coreutils-8.32-tail-use-poll.patch b/coreutils-8.32-tail-use-poll.patch new file mode 100644 index 0000000..ed3a8f3 --- /dev/null +++ b/coreutils-8.32-tail-use-poll.patch @@ -0,0 +1,181 @@ +From c7a04cef4075da864a3468e63a5bb79334d8f556 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Sat, 26 Jun 2021 18:23:52 -0700 +Subject: [PATCH] tail: use poll, not select +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This fixes an unlikely stack out-of-bounds write reported by +Stepan Broz via Kamil Dudka (Bug#49209). +* src/tail.c: Do not include . +[!_AIX]: Include poll.h. +(check_output_alive) [!_AIX]: Use poll instead of select. +(tail_forever_inotify): Likewise. Simplify logic, as there is no +need for a ‘while (len <= evbuf_off)’ loop. + +Upstream-commit: da0d448bca62c6305fc432f67e2c5ccc2da75346 +Signed-off-by: Kamil Dudka +--- + src/tail.c | 100 +++++++++++++++++++++-------------------------------- + 1 file changed, 39 insertions(+), 61 deletions(-) + +diff --git a/src/tail.c b/src/tail.c +index 1c88723..5b4f21a 100644 +--- a/src/tail.c ++++ b/src/tail.c +@@ -28,12 +28,9 @@ + #include + #include + #include +-#include ++#include + #include + #include +-#ifdef _AIX +-# include +-#endif + + #include "system.h" + #include "argmatch.h" +@@ -351,27 +348,12 @@ check_output_alive (void) + if (! monitor_output) + return; + +-#ifdef _AIX +- /* select on AIX was seen to give a readable event immediately. */ + struct pollfd pfd; + pfd.fd = STDOUT_FILENO; + pfd.events = POLLERR; + + if (poll (&pfd, 1, 0) >= 0 && (pfd.revents & POLLERR)) + die_pipe (); +-#else +- struct timeval delay; +- delay.tv_sec = delay.tv_usec = 0; +- +- fd_set rfd; +- FD_ZERO (&rfd); +- FD_SET (STDOUT_FILENO, &rfd); +- +- /* readable event on STDOUT is equivalent to POLLERR, +- and implies an error condition on output like broken pipe. */ +- if (select (STDOUT_FILENO + 1, &rfd, NULL, NULL, &delay) == 1) +- die_pipe (); +-#endif + } + + static bool +@@ -1612,7 +1594,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, + /* Wait for inotify events and handle them. Events on directories + ensure that watched files can be re-added when following by name. + This loop blocks on the 'safe_read' call until a new event is notified. +- But when --pid=P is specified, tail usually waits via the select. */ ++ But when --pid=P is specified, tail usually waits via poll. */ + while (1) + { + struct File_spec *fspec; +@@ -1629,54 +1611,51 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, + return false; + } + +- /* When watching a PID, ensure that a read from WD will not block +- indefinitely. */ +- while (len <= evbuf_off) ++ if (len <= evbuf_off) + { +- struct timeval delay; /* how long to wait for file changes. */ ++ /* Poll for inotify events. When watching a PID, ensure ++ that a read from WD will not block indefinitely. ++ If MONITOR_OUTPUT, also poll for a broken output pipe. */ + +- if (pid) ++ int file_change; ++ struct pollfd pfd[2]; ++ do + { +- if (writer_is_dead) +- exit (EXIT_SUCCESS); ++ /* How many ms to wait for changes. -1 means wait forever. */ ++ int delay = -1; + +- writer_is_dead = (kill (pid, 0) != 0 && errno != EPERM); +- +- if (writer_is_dead) +- delay.tv_sec = delay.tv_usec = 0; +- else ++ if (pid) + { +- delay.tv_sec = (time_t) sleep_interval; +- delay.tv_usec = 1000000 * (sleep_interval - delay.tv_sec); ++ if (writer_is_dead) ++ exit (EXIT_SUCCESS); ++ ++ writer_is_dead = (kill (pid, 0) != 0 && errno != EPERM); ++ ++ if (writer_is_dead || sleep_interval <= 0) ++ delay = 0; ++ else if (sleep_interval < INT_MAX / 1000 - 1) ++ { ++ /* delay = ceil (sleep_interval * 1000), sans libm. */ ++ double ddelay = sleep_interval * 1000; ++ delay = ddelay; ++ delay += delay < ddelay; ++ } + } ++ ++ pfd[0].fd = wd; ++ pfd[0].events = POLLIN; ++ pfd[1].fd = STDOUT_FILENO; ++ pfd[1].events = pfd[1].revents = 0; ++ file_change = poll (pfd, monitor_output + 1, delay); + } ++ while (file_change == 0); + +- fd_set rfd; +- FD_ZERO (&rfd); +- FD_SET (wd, &rfd); +- if (monitor_output) +- FD_SET (STDOUT_FILENO, &rfd); +- +- int file_change = select (MAX (wd, STDOUT_FILENO) + 1, +- &rfd, NULL, NULL, pid ? &delay: NULL); +- +- if (file_change == 0) +- continue; +- else if (file_change == -1) +- die (EXIT_FAILURE, errno, +- _("error waiting for inotify and output events")); +- else if (FD_ISSET (STDOUT_FILENO, &rfd)) +- { +- /* readable event on STDOUT is equivalent to POLLERR, +- and implies an error on output like broken pipe. */ +- die_pipe (); +- } +- else +- break; +- } ++ if (file_change < 0) ++ die (EXIT_FAILURE, errno, ++ _("error waiting for inotify and output events")); ++ if (pfd[1].revents) ++ die_pipe (); + +- if (len <= evbuf_off) +- { + len = safe_read (wd, evbuf, evlen); + evbuf_off = 0; + +@@ -2437,8 +2416,7 @@ main (int argc, char **argv) + if (forever && ignore_fifo_and_pipe (F, n_files)) + { + /* If stdout is a fifo or pipe, then monitor it +- so that we exit if the reader goes away. +- Note select() on a regular file is always readable. */ ++ so that we exit if the reader goes away. */ + struct stat out_stat; + if (fstat (STDOUT_FILENO, &out_stat) < 0) + die (EXIT_FAILURE, errno, _("standard output")); +-- +2.31.1 + diff --git a/coreutils.spec b/coreutils.spec index 95613b2..f402cd7 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 8.32 -Release: 19%{?dist} +Release: 20%{?dist} License: GPLv3+ Url: https://www.gnu.org/software/coreutils/ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz @@ -46,6 +46,9 @@ Patch10: coreutils-8.32-stat-exfat.patch # mountlist: recognize fuse.portal as dummy file system (#1913358) Patch15: coreutils-8.32-fuse-portal.patch +# tail: fix stack out-of-bounds write with --follow +Patch16: coreutils-8.32-tail-use-poll.patch + # disable the test-lock gnulib test prone to deadlock Patch100: coreutils-8.26-test-lock.patch @@ -299,6 +302,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Thu Jul 01 2021 Kamil Dudka - 8.32-20 +- tail: fix stack out-of-bounds write with --follow + * Tue Jun 08 2021 Kamil Dudka - 8.32-19 - mountlist: recognize fuse.portal as dummy file system (#1913358) From 6f1d6ab210fc58e433a2e11a80995e515b01b782 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 7 Jul 2021 17:59:02 +0200 Subject: [PATCH 4/4] Resolves: #1979814 - df: fix duplicated remote entries due to bind mounts --- coreutils-8.32-df-duplicated-entries.patch | 72 ++++++++++++++++++++++ coreutils.spec | 8 ++- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 coreutils-8.32-df-duplicated-entries.patch diff --git a/coreutils-8.32-df-duplicated-entries.patch b/coreutils-8.32-df-duplicated-entries.patch new file mode 100644 index 0000000..5d39c1e --- /dev/null +++ b/coreutils-8.32-df-duplicated-entries.patch @@ -0,0 +1,72 @@ +From 0f053de4bc3ca0cfd88a42d236881dfdddb10ee9 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. +Fixes https://bugs.gnu.org/49298 + +Upstream-commit: d6125af095c9553f38cba0696f15158f5abe4ecc +Signed-off-by: Kamil Dudka +--- + src/df.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +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.31.1 + diff --git a/coreutils.spec b/coreutils.spec index f402cd7..f0f7b32 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 8.32 -Release: 20%{?dist} +Release: 21%{?dist} License: GPLv3+ Url: https://www.gnu.org/software/coreutils/ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz @@ -49,6 +49,9 @@ Patch15: coreutils-8.32-fuse-portal.patch # tail: fix stack out-of-bounds write with --follow Patch16: coreutils-8.32-tail-use-poll.patch +# df: fix duplicated remote entries due to bind mounts (#1979814) +Patch17: coreutils-8.32-df-duplicated-entries.patch + # disable the test-lock gnulib test prone to deadlock Patch100: coreutils-8.26-test-lock.patch @@ -302,6 +305,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Wed Jul 07 2021 Kamil Dudka - 8.32-21 +- df: fix duplicated remote entries due to bind mounts (#1979814) + * Thu Jul 01 2021 Kamil Dudka - 8.32-20 - tail: fix stack out-of-bounds write with --follow