Merged
fix CVE-2025-45582 #64
fly_fzcAdd on Jan 6
fix CVE-2025-45582 #64
Merged
Total: 3 files changed+2765-1
| @@ -0,0 +1,163 @@ | |||
| 1 | +From c1027eb5aee7b2a942c601ef6cdb1b132da83225 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: Paul Eggert <eggert@cs.ucla.edu> | ||
| 3 | +Date: Thu, 9 Jun 2022 15:50:06 -0700 | ||
| 4 | +Subject: Warn “file changed as we read it” less often | ||
| 5 | +MIME-Version: 1.0 | ||
| 6 | +Content-Type: text/plain; charset=UTF-8 | ||
| 7 | +Content-Transfer-Encoding: 8bit | ||
| 8 | + | ||
| 9 | +* src/create.c (dump_file0): Remove an fstatat call that is | ||
| 10 | +unnecessary because the file wasn’t read so we can treat the first | ||
| 11 | +fstatat as atomic. Warn “file changed” when the file’s size, | ||
| 12 | +mtime, user ID, group ID, or mode changes, instead of when the | ||
| 13 | +file’s size or ctime changes. Also, when such a change happens, | ||
| 14 | +do not change exit status if --ignore-failed-read. Finally, don’t | ||
| 15 | +attempt to change atime back if it didn’t change. | ||
| 16 | +--- | ||
| 17 | + doc/tar.texi | 10 ++++++---- | ||
| 18 | + src/create.c | 54 ++++++++++++++++++++++++++++++++++++---------------- | ||
| 19 | + 2 files changed, 44 insertions(+), 20 deletions(-) | ||
| 20 | + | ||
| 21 | +diff --git a/doc/tar.texi b/doc/tar.texi | ||
| 22 | +index b66b163..dd5a272 100644 | ||
| 23 | +--- a/doc/tar.texi | ||
| 24 | ++++ b/doc/tar.texi | ||
| 25 | +@@ -2854,7 +2854,7 @@ Ignore exit codes of subprocesses. @xref{Writing to an External Program}. | ||
| 26 | + @opsummary{ignore-failed-read} | ||
| 27 | + @item --ignore-failed-read | ||
| 28 | + | ||
| 29 | +-Do not exit unsuccessfully merely because an unreadable file was encountered. | ||
| 30 | ++Do not exit unsuccessfully merely because reading failed. | ||
| 31 | + @xref{Ignore Failed Read}. | ||
| 32 | + | ||
| 33 | + @opsummary{ignore-zeros} | ||
| 34 | +@@ -4638,7 +4638,8 @@ Disable all warning messages. | ||
| 35 | + @item file-changed | ||
| 36 | + @samp{%s: file changed as we read it} | ||
| 37 | + @item failed-read | ||
| 38 | +-Suppresses warnings about unreadable files or directories. This | ||
| 39 | ++Suppresses warnings about read failures, which can occur if files | ||
| 40 | ++or directories are unreadable, or if they change while being read. This | ||
| 41 | + keyword applies only if used together with the @option{--ignore-failed-read} | ||
| 42 | + option. @xref{Ignore Failed Read}. | ||
| 43 | + @end table | ||
| 44 | +@@ -5761,11 +5762,12 @@ Disable SELinux context support. | ||
| 45 | + @table @option | ||
| 46 | + @item --ignore-failed-read | ||
| 47 | + @opindex ignore-failed-read | ||
| 48 | +-Do not exit with nonzero on unreadable files or directories. | ||
| 49 | ++Do not exit with nonzero if there are mild problems while reading. | ||
| 50 | + @end table | ||
| 51 | + | ||
| 52 | + This option has effect only during creation. It instructs tar to | ||
| 53 | +-treat as mild conditions any missing or unreadable files (directories). | ||
| 54 | ++treat as mild conditions any missing or unreadable files (directories), | ||
| 55 | ++or files that change while reading. | ||
| 56 | + Such failures don't affect the program exit code, and the | ||
| 57 | + corresponding diagnostic messages are marked as warnings, not errors. | ||
| 58 | + These warnings can be suppressed using the | ||
| 59 | +diff --git a/src/create.c b/src/create.c | ||
| 60 | +index e2816fc..2b3001d 100644 | ||
| 61 | +--- a/src/create.c | ||
| 62 | ++++ b/src/create.c | ||
| 63 | +@@ -1650,8 +1650,6 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) | ||
| 64 | + { | ||
| 65 | + union block *header; | ||
| 66 | + char type; | ||
| 67 | +- off_t original_size; | ||
| 68 | +- struct timespec original_ctime; | ||
| 69 | + off_t block_ordinal = -1; | ||
| 70 | + int fd = 0; | ||
| 71 | + bool is_dir; | ||
| 72 | +@@ -1694,10 +1692,11 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) | ||
| 73 | + return; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | +- st->archive_file_size = original_size = st->stat.st_size; | ||
| 77 | ++ struct stat st1 = st->stat; | ||
| 78 | ++ st->archive_file_size = st->stat.st_size; | ||
| 79 | + st->atime = get_stat_atime (&st->stat); | ||
| 80 | + st->mtime = get_stat_mtime (&st->stat); | ||
| 81 | +- st->ctime = original_ctime = get_stat_ctime (&st->stat); | ||
| 82 | ++ st->ctime = get_stat_ctime (&st->stat); | ||
| 83 | + | ||
| 84 | + #ifdef S_ISHIDDEN | ||
| 85 | + if (S_ISHIDDEN (st->stat.st_mode)) | ||
| 86 | +@@ -1747,7 +1746,7 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) | ||
| 87 | + if (is_dir || S_ISREG (st->stat.st_mode) || S_ISCTG (st->stat.st_mode)) | ||
| 88 | + { | ||
| 89 | + bool ok; | ||
| 90 | +- struct stat final_stat; | ||
| 91 | ++ struct stat st2; | ||
| 92 | + | ||
| 93 | + xattrs_acls_get (parentfd, name, st, 0, !is_dir); | ||
| 94 | + xattrs_selinux_get (parentfd, name, st, fd); | ||
| 95 | +@@ -1815,31 +1814,54 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) | ||
| 96 | + errno = - parentfd; | ||
| 97 | + ok = false; | ||
| 98 | + } | ||
| 99 | +- else | ||
| 100 | +- ok = fstatat (parentfd, name, &final_stat, fstatat_flags) == 0; | ||
| 101 | + } | ||
| 102 | + else | ||
| 103 | +- ok = fstat (fd, &final_stat) == 0; | ||
| 104 | ++ ok = fstat (fd, &st2) == 0; | ||
| 105 | + | ||
| 106 | + if (! ok) | ||
| 107 | + file_removed_diag (p, top_level, stat_diag); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | +- if (ok) | ||
| 111 | ++ if (ok && fd) | ||
| 112 | + { | ||
| 113 | +- if ((timespec_cmp (get_stat_ctime (&final_stat), original_ctime) != 0 | ||
| 114 | +- /* Original ctime will change if the file is a directory and | ||
| 115 | +- --remove-files is given */ | ||
| 116 | +- && !(remove_files_option && is_dir)) | ||
| 117 | +- || original_size < final_stat.st_size) | ||
| 118 | ++ /* Heuristically check whether the file is the same in all | ||
| 119 | ++ attributes that tar cares about and can easily check. | ||
| 120 | ++ Although the check is not perfect since it does not | ||
| 121 | ++ consult file contents, it is typically good enough. | ||
| 122 | ++ Do not check atime which is saved only to replace it later. | ||
| 123 | ++ Do not check ctime where changes might be benign (e.g., | ||
| 124 | ++ another process creates a hard link to the file). */ | ||
| 125 | ++ | ||
| 126 | ++ /* If the file's user ID, group ID or mode changed, tar may | ||
| 127 | ++ have output the wrong info for the file. */ | ||
| 128 | ++ ok &= st1.st_uid == st2.st_uid; | ||
| 129 | ++ ok &= st1.st_gid == st2.st_gid; | ||
| 130 | ++ ok &= st1.st_mode == st2.st_mode; | ||
| 131 | ++ | ||
| 132 | ++ /* Likewise for the file's mtime, but skip this check if it | ||
| 133 | ++ is a directory possibly updated by --remove-files. */ | ||
| 134 | ++ if (! (is_dir && remove_files_option)) | ||
| 135 | ++ ok &= ! timespec_cmp (get_stat_mtime (&st1), | ||
| 136 | ++ get_stat_mtime (&st2)); | ||
| 137 | ++ | ||
| 138 | ++ /* Likewise for the file's size, but skip this check if it | ||
| 139 | ++ is a directory as tar does not output directory sizes. | ||
| 140 | ++ Although dump_regular_file caught regular file shrinkage, | ||
| 141 | ++ it shouldn't hurt to check for shrinkage again now; | ||
| 142 | ++ plus, the file may have grown. */ | ||
| 143 | ++ if (!is_dir) | ||
| 144 | ++ ok &= st1.st_size == st2.st_size; | ||
| 145 | ++ | ||
| 146 | ++ if (!ok) | ||
| 147 | + { | ||
| 148 | + WARNOPT (WARN_FILE_CHANGED, | ||
| 149 | + (0, 0, _("%s: file changed as we read it"), | ||
| 150 | + quotearg_colon (p))); | ||
| 151 | +- set_exit_status (TAREXIT_DIFFERS); | ||
| 152 | ++ if (! ignore_failed_read_option) | ||
| 153 | ++ set_exit_status (TAREXIT_DIFFERS); | ||
| 154 | + } | ||
| 155 | + else if (atime_preserve_option == replace_atime_preserve | ||
| 156 | +- && fd && (is_dir || original_size != 0) | ||
| 157 | ++ && timespec_cmp (st->atime, get_stat_atime (&st2)) != 0 | ||
| 158 | + && set_file_atime (fd, parentfd, name, st->atime) != 0 | ||
| 159 | + && errno != EROFS ) | ||
| 160 | + utime_error (p); | ||
| 161 | +-- | ||
| 162 | +2.45.2 | ||
| 163 | + | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | Name: tar | 1 | Name: tar |
| 2 | Version: 1.34 | 2 | Version: 1.34 |
| 3 | -Release: 5 | 3 | +Release: 6 |
| 4 | Epoch: 2 | 4 | Epoch: 2 |
| 5 | Summary: An organized and systematic method of controlling a large amount of data | 5 | Summary: An organized and systematic method of controlling a large amount of data |
| 6 | License: GPLv3+ | 6 | License: GPLv3+ |
| @@ -21,6 +21,8 @@ Patch0004: tar-1.28-atime-rofs.patch | |||
| 21 | Patch0005: tar-1.28-document-exclude-mistakes.patch | 21 | Patch0005: tar-1.28-document-exclude-mistakes.patch |
| 22 | Patch0006: tar-Add-sw64-architecture.patch | 22 | Patch0006: tar-Add-sw64-architecture.patch |
| 23 | Patch0007: backport-CVE-2023-39804.patch | 23 | Patch0007: backport-CVE-2023-39804.patch |
| 24 | +Patch0008: Warn-file-changed-as-we-read-it-less-often.patch | ||
| 25 | +Patch0009: CVE-2025-45582.patch | ||
| 24 | 26 | ||
| 25 | %description | 27 | %description |
| 26 | GNU Tar provides the ability to create tar archives, as well as various other | 28 | GNU Tar provides the ability to create tar archives, as well as various other |
| @@ -79,6 +81,9 @@ make check | |||
| 79 | %{_infodir}/tar.info* | 81 | %{_infodir}/tar.info* |
| 80 | 82 | ||
| 81 | %changelog | 83 | %changelog |
| 84 | +* Tue Jan 06 2026 fuanan <fuanan3@h-partners.com> - 2:1.34-6 | ||
| 85 | +- fix CVE-2025-45582 | ||
| 86 | + | ||
| 82 | * Mon Dec 04 2023 liningjie <liningjie@xfusion.com> 2:1.34-5 | 87 | * Mon Dec 04 2023 liningjie <liningjie@xfusion.com> 2:1.34-5 |
| 83 | - fix CVE-2023-39840 | 88 | - fix CVE-2023-39840 |
| 84 | 89 | ||