coreutils: patch possible infinite loop with SEEK_HOLE
authorWei-Ting Yang <redacted>
Fri, 9 Jan 2026 12:14:24 +0000 (20:14 +0800)
committerHannu Nyman <redacted>
Sun, 18 Jan 2026 05:19:37 +0000 (07:19 +0200)
cp, install, and mv no longer enter an infinite loop copying sparse files
with SEEK_HOLE. E.g., this was seen on ext4 when copying sparse files with
extents that are being actively updated, and copy offload is not being used.

See also:
https://github.com/coreutils/coreutils/commit/bd528f923482223649aa84be7d131e69356149da

Signed-off-by: Wei-Ting Yang <redacted>
utils/coreutils/Makefile
utils/coreutils/patches/000-copy-fix-possible-infinite-loop-with-SEEK_HOLE.patch [new file with mode: 0644]
utils/coreutils/patches/900-no_docs_man_tests.patch [moved from utils/coreutils/patches/001-no_docs_man_tests.patch with 100% similarity]

index b5f26fc9426b4d5b4a54ef6e517f945b4d732f4b..08c8d0b5a728ee556ca4831d33abbc1cab180279 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=coreutils
 PKG_VERSION:=9.9
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@GNU/coreutils
diff --git a/utils/coreutils/patches/000-copy-fix-possible-infinite-loop-with-SEEK_HOLE.patch b/utils/coreutils/patches/000-copy-fix-possible-infinite-loop-with-SEEK_HOLE.patch
new file mode 100644 (file)
index 0000000..3406fe5
--- /dev/null
@@ -0,0 +1,26 @@
+From bd528f923482223649aa84be7d131e69356149da Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
+Date: Sun, 4 Jan 2026 12:45:46 +0000
+Subject: [PATCH] copy: fix possible infinite loop with SEEK_HOLE
+
+Commit v9.8-95-g4c0cf3864 intended to initialize
+ext_start to src_pos, as was described at:
+https://lists.gnu.org/r/coreutils/2025-11/msg00035.html
+However ipos was inadvertently used, which is only
+valid the first time through the loop.
+
+* src/copy-file-data.c (lseek_copy): Use scan_inference->hole_start
+only with the initial offset passed to lseek_copy().
+Reported at https://github.com/coreutils/coreutils/issues/159
+
+--- a/src/copy-file-data.c
++++ b/src/copy-file-data.c
+@@ -338,7 +338,7 @@ lseek_copy (int src_fd, int dest_fd, cha
+   for (off_t ext_start = scan_inference->ext_start;
+        0 <= ext_start && ext_start < max_ipos; )
+     {
+-      off_t ext_end = (ext_start == ipos
++      off_t ext_end = (ext_start == src_pos
+                        ? scan_inference->hole_start
+                        : lseek (src_fd, ext_start, SEEK_HOLE));
+       if (0 <= ext_end)
git clone https://git.99rst.org/PROJECT