Reproduced this in a 32-bit test container. The failure boundary is
exactly 2 GiB (i32::MAX = 2,147,483,647 bytes). Any file >= 2 GiB fails
immediately with EOVERFLOW ("Value too large for defined data type").

The root cause is in uucore::safe_traversal::DirFd: `stat_at` and
`fstat` call nix::sys::stat::fstatat/fstat. On 32-bit Linux targets, nix
uses the non-LFS libc wrappers with 32-bit off_t. When the kernel
returns a file size >= 2 GiB (such as gcc-snapshot-dbgsym) or a 64-bit
inode, glibc returns EOVERFLOW. Callers like chmod, du, and rm only need
file type and permissions to traverse the tree, but abort because stat
returns an error.

I prepared a surgical patch for Ubuntu stonking: upon Err(EOVERFLOW),
safe_traversal falls back to libc::fstatat64 and libc::fstat64,
saturating st_size to off_t::MAX for 32-bit callers.

Verified with 32-bit i386 binaries on a 5 GiB test file:
- chmod -Rv u+rw: exit code 0
- du -sh: exit code 0
- rm -rf: exit code 0
- All 37 uucore safe_traversal unit tests pass.

Attaching debdiff for rust-coreutils 0.12.0-1ubuntu2 against stonking.
Upstream PR: https://github.com/uutils/coreutils/pull/14798
Related bug: LP: #2148301


** Patch added: "rust-coreutils_0.12.0-1ubuntu2.debdiff"
   
https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2167794/+attachment/6002521/+files/rust-coreutils_0.12.0-1ubuntu2.debdiff

** Tags added: armhf i386 patch stonking

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2167794

Title:
  chmod: Value too large for defined data type on armhf and i386

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2167794/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to