diff --git a/backport-dd-fix-error-detection-with-nocache-flag.patch b/backport-dd-fix-error-detection-with-nocache-flag.patch new file mode 100644 index 0000000000000000000000000000000000000000..54a557d0807c6ea9aa800b5aa2317c7c1b0d7ce7 --- /dev/null +++ b/backport-dd-fix-error-detection-with-nocache-flag.patch @@ -0,0 +1,40 @@ +From 37b085e567c9c16473ec0d9285ed3a47e861dc24 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Yhuel?= +Date: Sun, 9 Mar 2025 19:12:14 +0000 +Subject: [PATCH] dd: fix error detection with "nocache" flag + +* src/dd.c (invalidate_cache): Adjust to the unusual +error propagation sematics of posix_fadvise(). +--- + src/dd.c | 6 ++++-- + 1 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/dd.c b/src/dd.c +index 4e914336b9..d549105169 100644 +--- a/src/dd.c ++++ b/src/dd.c +@@ -1027,7 +1027,8 @@ cache_round (int fd, off_t len) + + /* Discard the cache from the current offset of either + STDIN_FILENO or STDOUT_FILENO. +- Return true on success. */ ++ Return true on success. ++ Return false on failure, with errno set. */ + + static bool + invalidate_cache (int fd, off_t len) +@@ -1087,12 +1088,13 @@ invalidate_cache (int fd, off_t len) + if (clen == 0) + offset -= offset % page_size; + adv_ret = posix_fadvise (fd, offset, clen, POSIX_FADV_DONTNEED); ++ errno = adv_ret; + #else + errno = ENOTSUP; + #endif + } + +- return adv_ret != -1 ? true : false; ++ return adv_ret == 0; + } + + /* Read from FD into the buffer BUF of size SIZE, processing any diff --git a/backport-tests-dd-ensure-posix_fadvise-errors-are-handled.patch b/backport-tests-dd-ensure-posix_fadvise-errors-are-handled.patch new file mode 100644 index 0000000000000000000000000000000000000000..6c9081a1f987bef7d80e01fd86573b69c4119f31 --- /dev/null +++ b/backport-tests-dd-ensure-posix_fadvise-errors-are-handled.patch @@ -0,0 +1,86 @@ +From 2b0887fdd507337c58ba964c283d73336a8da2cc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Mon, 10 Mar 2025 12:33:20 +0000 +Subject: [PATCH] tests: dd: ensure posix_fadvise errors are handled + +* tests/dd/nocache_fail.sh: Add a test case for the recent fix. +--- + tests/dd/nocache_fail.sh | 56 ++++++++++++++++++++++++++++++++++++++++ + tests/local.mk | 1 + + 2 files changed, 57 insertions(+) + create mode 100755 tests/dd/nocache_fail.sh + +diff --git a/tests/dd/nocache_fail.sh b/tests/dd/nocache_fail.sh +new file mode 100755 +index 0000000000..4d30c8558d +--- /dev/null ++++ b/tests/dd/nocache_fail.sh +@@ -0,0 +1,56 @@ ++#!/bin/sh ++# Ensure we diagnose failure to drop caches ++# We didn't check the return from posix_fadvise() correctly before v9.7 ++ ++# Copyright (C) 2025 Free Software Foundation, Inc. ++ ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program 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 General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src ++print_ver_ dd ++require_gcc_shared_ ++ ++# Replace each getxattr and lgetxattr call with a call to these stubs. ++# Count those and write the total number of calls to the file "x" ++# via a global destructor. ++cat > k.c <<'EOF' || framework_failure_ ++#include ++#include ++#include ++#include ++ ++int posix_fadvise (int fd, off_t offset, off_t len, int advice) ++{ ++ fopen ("called", "w"); ++ return ENOTSUP; /* Simulate non standard error indication. */ ++} ++EOF ++ ++# Then compile/link it: ++gcc_shared_ k.c k.so \ ++ || framework_failure_ 'failed to build shared library' ++ ++touch ifile || framework_failure_ ++ ++LD_PRELOAD=$LD_PRELOAD:./k.so dd if=ifile iflag=nocache count=0 2>err ++ret=$? ++ ++test -f called || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" ++ ++grep 'dd: failed to discard cache for: ifile' err || fail=1 ++ ++# Ensure that the dd command failed ++test "$ret" = 1 || fail=1 ++ ++Exit $fail +diff --git a/tests/local.mk b/tests/local.mk +index 12e30b449b..4da6756ac6 100644 +--- a/tests/local.mk ++++ b/tests/local.mk +@@ -553,6 +553,7 @@ all_tests = \ + tests/dd/no-allocate.sh \ + tests/dd/nocache.sh \ + tests/dd/nocache_eof.sh \ ++ tests/dd/nocache_fail.sh \ + tests/dd/not-rewound.sh \ + tests/dd/reblock.sh \ + tests/dd/skip-seek.pl \ diff --git a/backport-timeout-ensure-infinitesimal-timeouts-timeout-quickl.patch b/backport-timeout-ensure-infinitesimal-timeouts-timeout-quickl.patch new file mode 100644 index 0000000000000000000000000000000000000000..0a5f140306f3e462d2e1461b13b5ea071d090dc7 --- /dev/null +++ b/backport-timeout-ensure-infinitesimal-timeouts-timeout-quickl.patch @@ -0,0 +1,40 @@ +From 026d0d7c40d2b585d153bb597b336442c14f2d18 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Fri, 4 Apr 2025 20:40:26 +0100 +Subject: [PATCH] timeout: ensure infinitesimal timeouts timeout quickly + +* src/timeout.c (parse_duration): Clamp infinitesimal values to 1ns. +* tests/timeout/timeout-large-parameters.sh: Add a test case. +Fixes https://bugs.gnu.org/77535 +--- + src/timeout.c | 4 ++++ + tests/timeout/timeout-large-parameters.sh | 3 +++ + 2 files changed, 7 insertions(+) + +diff --git a/src/timeout.c b/src/timeout.c +index 578d71070d..6756cd8881 100644 +--- a/src/timeout.c ++++ b/src/timeout.c +@@ -371,6 +371,10 @@ parse_duration (char const *str) + usage (EXIT_CANCELED); + } + ++ /* Clamp underflow to 1ns, as 0 disables the timeout. */ ++ if (duration == 0 && errno == ERANGE) ++ duration = 1e-9; ++ + return duration; + } + +diff --git a/tests/timeout/timeout-large-parameters.sh b/tests/timeout/timeout-large-parameters.sh +index 5669810e8a..a5395d153f 100755 +--- a/tests/misc/timeout-large-parameters.sh ++++ b/tests/misc/timeout-large-parameters.sh +@@ -43,4 +43,7 @@ timeout 2.34e+5d sleep 0 || fail=1 + timeout $LDBL_MAX sleep 0 || fail=1 + returns_ 125 timeout -- -$LDBL_MAX sleep 0 || fail=1 + ++# Ensure underflow times out immediately ++returns_ 124 timeout 1e-5000 sleep 10 || fail=1 ++ + Exit $fail diff --git a/coreutils.spec b/coreutils.spec index 053579d0f7383c93b08b2992fa5f9b49c02caff9..b44f458d316114e274a81b77bf3312f991299846 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils Version: 9.0 -Release: 20 +Release: 21 License: GPLv3+ Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ @@ -64,6 +64,9 @@ patch49: backport-tac-avoid-out-of-bounds-access.patch Patch50: backport-yes-avoid-failure-on-CHERI-protected-systems.patch Patch51: backport-tail-avoid-infloop-with-c-on-dev-zero.patch Patch52: backport-CVE-2025-5278.patch +Patch53: backport-dd-fix-error-detection-with-nocache-flag.patch +Patch54: backport-tests-dd-ensure-posix_fadvise-errors-are-handled.patch +Patch55: backport-timeout-ensure-infinitesimal-timeouts-timeout-quickl.patch Patch9001: coreutils-9.0-sw.patch @@ -192,6 +195,9 @@ fi %{_mandir}/man*/* %changelog +* Thu Aug 21 2025 yanglongkang - 9.0-21 +- sync patches from community + * Sat May 31 2025 Funda Wang - 9.0-20 - fix CVE-2025-5278