Change #254364
| Category | gcoreutils |
| Changed by | Pádraig Brady <P@draigBrady.com> |
| Changed at | Tue 06 Jan 2026 21:41:15 |
| Repository | git://git.savannah.gnu.org/coreutils.git |
| Project | gcoreutils |
| Branch | master |
| Revision | 33bc44e1ba3aa4c70f3cd16aa9c41331543986dd |
Comments
copy: protect against infinite loop due to pathological race
Consider:
1. In infer_scantype():
- SEEK_DATA returns 0
- hole punched at 0
- SEEK_HOLE returns 0 (now a hole)
- Cache scan_inference->hole_start = 0
2. In lseek_copy():
- data written at 0
- ext_start = 0, use cached hole_start = 0
- ext_len = 0
- now loop doesn't progress
* src/copy-file-data.c (lseek_copy): Apply a more defensive check
to ensure we only use the cached offsets in SCAN_INFERENCE once.
This protects against an infinite loop where an extent (at SRC_POS)
flip flops between data and hole extent while infer_scantype()
and lseek_copy() are inspecting it. I.e. ensure we use SEEK_HOLE
to progress the copy.
Changed files
- src/copy-file-data.c