Reproduced on armhf under stonking.

Root cause:
On 32-bit Linux, nix::dir::Dir calls glibc 32-bit readdir(). When directory 
offsets (d_off) exceed 31 bits (common with OverlayFS, tmpfs, or ext4 64-bit 
dirhash on 64-bit kernels), readdir() returns EOVERFLOW ("Value too large for 
defined data type").
In uu_rm safe_remove_dir_recursive, directory read errors were silenced by 
handle_error_with_force(), leaving files in the directory intact and causing 
subsequent rmdir() to fail with ENOTEMPTY ("Directory not empty").

Fix:
Switch read_dir_entries() in uucore safe_traversal from nix::dir::Dir to 
rustix::fs::Dir. It calls readdir64/getdents64 on Linux, handling 64-bit 
offsets without overflow on 32-bit.

Upstream PR:
https://github.com/uutils/coreutils/pull/15036

Tested on armhf container:
- Before: rm -rf on /var/lib/dpkg/tmp.ci fails with "Directory not empty" (exit 
1).
- After: rm -rf removes the directory and all entries cleanly (exit 0). Package 
installation via dpkg/apt finishes without cleanup errors.

Attached debdiff:
rust-coreutils_0.12.0-1ubuntu2.debdiff (applies with 0 fuzz against 
0.12.0-1ubuntu1.dsc).


** Description changed:

+ [ Impact ]
+ 
+ On 32-bit armhf stonking, apt/dpkg fails during package cleanup:
+   rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
+   dpkg: error while cleaning up: rm command for cleanup subprocess failed 
with exit status 1
+ 
+ read_dir_entries() in uucore uses nix::dir::Dir, which calls glibc
+ 32-bit readdir(). When directory offsets (d_off) exceed 31 bits (common
+ on 64-bit kernels with OverlayFS, tmpfs, or ext4 64-bit dirhash),
+ readdir() fails with EOVERFLOW.
+ 
+ In uu_rm, read errors in rm -rf were swallowed by
+ handle_error_with_force(), leaving files in place. The following rmdir()
+ then fails with ENOTEMPTY. This breaks package installation on armhf.
+ 
+ [ Fix ]
+ 
+ Switch read_dir_entries() in uucore safe_traversal from nix::dir::Dir to
+ rustix::fs::Dir, which uses 64-bit readdir64/getdents64.
+ 
+ [ Test Plan ]
+ 
+ 1. In an armhf stonking container:
+    mkdir -p /var/lib/dpkg/tmp.ci && touch /var/lib/dpkg/tmp.ci/control
+    rm -rf /var/lib/dpkg/tmp.ci
+    or:
+    apt-get update && apt-get install -y openssl
+ 2. Without patch:
+    rm fails with:
+    rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty (exit 1)
+ 3. With patch:
+    Exit 0, directory is removed, apt/dpkg finishes cleanly.
+ 
+ [ Where problems could occur ]
+ 
+ Changes are limited to directory enumeration in safe_traversal. If
+ rustix had an issue in directory iteration, utilities like rm or chmod
+ could fail to list directory entries. Tested with cargo unit tests and
+ live rm on armhf.
+ 
+ [ Other Info ]
+ 
+ - Upstream PR: https://github.com/uutils/coreutils/pull/15036
+ - Target devel series: stonking (Ubuntu 26.10)
+ - Debdiff attached: rust-coreutils_0.12.0-1ubuntu2.debdiff (applies cleanly 
against archive 0.12.0-1ubuntu1.dsc with 0 fuzz, 0 rejects).
+ 
+ 
+ ----- Old Descr. -----
+ 
+ 
  On Ubuntu Stonking on the armhf architecture, `dpkg` is failing whenever I 
try to `apt install` any package, with the following error:
  ```
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error while cleaning up:
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  ```
  
  I was able to reproduce this in a docker environment as well:
  ```
  ➜  docker run --rm -it --platform linux/armhf ubuntu:26.10 bash
  
  root@ffa63238f77e:/# apt-get update
  Get:1 http://ports.ubuntu.com/ubuntu-ports stonking InRelease [170 kB]
  Get:2 http://ports.ubuntu.com/ubuntu-ports stonking-updates InRelease [60.7 
kB]
  Get:3 http://ports.ubuntu.com/ubuntu-ports stonking-backports InRelease [60.7 
kB]
  Get:4 http://ports.ubuntu.com/ubuntu-ports stonking-security InRelease [60.7 
kB]
  Get:5 http://ports.ubuntu.com/ubuntu-ports stonking/restricted armhf Packages 
[890 B]
  Get:6 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf Packages [1180 
kB]
  Get:7 http://ports.ubuntu.com/ubuntu-ports stonking/universe armhf Packages 
[13.7 MB]
  Get:8 http://ports.ubuntu.com/ubuntu-ports stonking/multiverse armhf Packages 
[151 kB]
  Fetched 15.4 MB in 5s (2850 kB/s)
  Reading package lists... Done
  root@ffa63238f77e:/# apt-get install curl
  Reading package lists... Done
  Building dependency tree... Done
  Reading state information... Done
  Solving dependencies... Done
  The following additional packages will be installed:
-   bash-completion ca-certificates krb5-locales libbrotli1 libcurl4t64 
libgssapi-krb5-2 libidn2-0 libk5crypto3 libkeyutils1
-   libkrb5-3 libkrb5support0 libldap-common libldap2 libnghttp2-14 libpsl5t64 
libsasl2-2 libsasl2-modules libsasl2-modules-db
-   libssh2-1t64 libunistring5 libupki-openssl1 openssl publicsuffix upki
+   bash-completion ca-certificates krb5-locales libbrotli1 libcurl4t64 
libgssapi-krb5-2 libidn2-0 libk5crypto3 libkeyutils1
+   libkrb5-3 libkrb5support0 libldap-common libldap2 libnghttp2-14 libpsl5t64 
libsasl2-2 libsasl2-modules libsasl2-modules-db
+   libssh2-1t64 libunistring5 libupki-openssl1 openssl publicsuffix upki
  Suggested packages:
-   krb5-doc krb5-user libsasl2-modules-gssapi-mit | 
libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp
-   libsasl2-modules-sql
+   krb5-doc krb5-user libsasl2-modules-gssapi-mit | 
libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp
+   libsasl2-modules-sql
  The following NEW packages will be installed:
-   bash-completion ca-certificates curl krb5-locales libbrotli1 libcurl4t64 
libgssapi-krb5-2 libidn2-0 libk5crypto3
-   libkeyutils1 libkrb5-3 libkrb5support0 libldap-common libldap2 
libnghttp2-14 libpsl5t64 libsasl2-2 libsasl2-modules
-   libsasl2-modules-db libssh2-1t64 libunistring5 libupki-openssl1 openssl 
publicsuffix upki
+   bash-completion ca-certificates curl krb5-locales libbrotli1 libcurl4t64 
libgssapi-krb5-2 libidn2-0 libk5crypto3
+   libkeyutils1 libkrb5-3 libkrb5support0 libldap-common libldap2 
libnghttp2-14 libpsl5t64 libsasl2-2 libsasl2-modules
+   libsasl2-modules-db libssh2-1t64 libunistring5 libupki-openssl1 openssl 
publicsuffix upki
  0 upgraded, 25 newly installed, 0 to remove and 8 not upgraded.
  Need to get 5852 kB of archives.
  After this operation, 16.6 MB of additional disk space will be used.
  Do you want to continue? [Y/n] y
  Get:1 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf openssl armhf 
4.0.1-1ubuntu4 [1258 kB]
  Get:2 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf 
ca-certificates all 20260816 [135 kB]
  Get:3 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf krb5-locales 
all 1.22.1-3ubuntu2 [14.0 kB]
  Get:4 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf 
libkrb5support0 armhf 1.22.1-3ubuntu2 [31.1 kB]
  Get:5 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libk5crypto3 
armhf 1.22.1-3ubuntu2 [79.2 kB]
  Get:6 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libkeyutils1 
armhf 1.6.3-6ubuntu3 [9366 B]
  Get:7 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libkrb5-3 
armhf 1.22.1-3ubuntu2 [321 kB]
  Get:8 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf 
libgssapi-krb5-2 armhf 1.22.1-3ubuntu2 [122 kB]
  Get:9 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libunistring5 
armhf 1.4.2-1 [587 kB]
  Get:10 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libidn2-0 
armhf 2.3.8-5 [96.5 kB]
  Get:11 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf 
bash-completion all 1:2.16.0-8build1 [214 kB]
  Get:12 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libnghttp2-14 
armhf 1.70.0-1 [66.3 kB]
  Get:13 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libpsl5t64 
armhf 0.23.3-1 [59.4 kB]
  Get:14 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf publicsuffix 
all 20260725.1419-1 [140 kB]
  Get:15 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libbrotli1 
armhf 1.2.0-4 [318 kB]
  Get:16 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf 
libsasl2-modules-db armhf 2.1.28+dfsg1-11ubuntu2 [17.0 kB]
  Get:17 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libsasl2-2 
armhf 2.1.28+dfsg1-11ubuntu2 [49.9 kB]
  Get:18 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf 
libldap-common all 2.6.13+dfsg-1ubuntu3 [26.1 kB]
  Get:19 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libldap2 
armhf 2.6.13+dfsg-1ubuntu3 [170 kB]
  Get:20 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libssh2-1t64 
armhf 1.11.1-4ubuntu3 [117 kB]
  Get:21 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf 
libupki-openssl1 armhf 1.0.0~beta.3+repack-0ubuntu2 [263 kB]
  Get:22 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf libcurl4t64 
armhf 8.20.0-2ubuntu10 [369 kB]
  Get:23 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf curl armhf 
8.20.0-2ubuntu10 [267 kB]
  Get:24 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf 
libsasl2-modules armhf 2.1.28+dfsg1-11ubuntu2 [61.1 kB]
  Get:25 http://ports.ubuntu.com/ubuntu-ports stonking/main armhf upki armhf 
1.0.0~beta.3+repack-0ubuntu2 [1059 kB]
  Fetched 5852 kB in 3s (2311 kB/s)
  debconf: unable to initialize frontend: Dialog
  debconf: (No usable dialog-like program is installed, so the dialog based 
frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 
79, <STDIN> line 25.)
  debconf: falling back to frontend: Readline
  debconf: unable to initialize frontend: Readline
  debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the 
Term::ReadLine module) (@INC entries checked: /etc/perl 
/usr/local/lib/arm-linux-gnueabihf/perl/5.40.1 /usr/local/share/perl/5.40.1 
/usr/lib/arm-linux-gnueabihf/perl5/5.40 /usr/share/perl5 
/usr/lib/arm-linux-gnueabihf/perl-base /usr/lib/arm-linux-gnueabihf/perl/5.40 
/usr/share/perl/5.40 /usr/local/lib/site_perl) at 
/usr/share/perl5/Debconf/FrontEnd/Readline.pm line 8, <STDIN> line 25.)
  debconf: falling back to frontend: Teletype
  Preconfiguring packages ...
  Selecting previously unselected package openssl.
  (Reading database ... 8692 files and directories currently installed.)
  Preparing to unpack .../00-openssl_4.0.1-1ubuntu4_armhf.deb ...
  Unpacking openssl (4.0.1-1ubuntu4) ...
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error while cleaning up:
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/01-ca-certificates_20260816_all.deb (--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/02-krb5-locales_1.22.1-3ubuntu2_all.deb (--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/03-libkrb5support0_1.22.1-3ubuntu2_armhf.deb 
(--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/04-libk5crypto3_1.22.1-3ubuntu2_armhf.deb 
(--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/05-libkeyutils1_1.6.3-6ubuntu3_armhf.deb 
(--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/06-libkrb5-3_1.22.1-3ubuntu2_armhf.deb (--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/07-libgssapi-krb5-2_1.22.1-3ubuntu2_armhf.deb 
(--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/08-libunistring5_1.4.2-1_armhf.deb (--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/09-libidn2-0_2.3.8-5_armhf.deb (--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/10-bash-completion_1%3a2.16.0-8build1_all.deb 
(--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  rm: cannot remove '/var/lib/dpkg/tmp.ci': Directory not empty
  dpkg: error processing archive 
/tmp/apt-dpkg-install-mPd3Ke/11-libnghttp2-14_1.70.0-1_armhf.deb (--unpack):
-  rm command for cleanup subprocess failed with exit status 1
+  rm command for cleanup subprocess failed with exit status 1
  
  root@4ecf0321a01f:/# dpkg --version
  Debian 'dpkg' package management program version 1.23.7 (armhf).
  This is free software; see the GNU General Public License version 2 or
  later for copying conditions. There is NO warranty.
  ```

** Patch added: "rust-coreutils 0.12.0-1ubuntu2 debdiff for stonking"
   
https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2169271/+attachment/6004960/+files/rust-coreutils_0.12.0-1ubuntu2.debdiff

** Tags added: armhf dpkg patch stonking

** Changed in: rust-coreutils (Ubuntu)
       Status: New => Confirmed

** Changed in: dpkg (Ubuntu)
       Status: New => Invalid

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

Title:
  dpkg fails on Stonking on armhf architecture

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/dpkg/+bug/2169271/+subscriptions


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

Reply via email to