Bug#969223: Can't rm directory on overlayfs in userns
On Wed, Mar 03, 2021 at 11:30:20AM +0100, Nicolas Schier wrote:
> On Wed 03 Mar 2021 17:33:16 GMT Shengjing Zhu write:
> >
> > On Wed, Mar 3, 2021 at 3:40 PM Nicolas Schier <nicolas@fjasle.eu> wrote:
> > > > [2]: https://lore.kernel.org/linux-unionfs/CAJfpegsiuf8ib5cvVrr=zHZ+Xu7BMMTT2eYapsEUdmPcRBUiwQ@mail.gmail.com/T/#t
> > >
> > > The overlay fs patchset [2] has been merged and with v5.10.13 (tested
> > > on linux-image-5.10.0-3-arm64) the issue is no more reproducible for
> > > me. Might you want to re-check on your site?
> > >
> >
> > If I understand correctly, the upstream patch is merged into the v5.11 tree.
>
> Sorry. Yes, you're right.
>
> > And I still can reproduce the error on the Debian v5.10 kernel.
>
> That confuses me quite a bit. I did it once again on an ext4 mount
> (still the 5.10.0-3-arm64 kernel):
>
> nsc@lillesand:/tmp$ cat /sys/module/overlay/parameters/permit_mounts_in_userns
> Y
> nsc@lillesand:/tmp$ mkdir -p test/lower/a test/merged test/upper test/work
> nsc@lillesand:/tmp$ uname -a | tee test/lower/a/a
> Linux lillesand 5.10.0-3-arm64 #1 SMP Debian 5.10.13-1 (2021-02-06) aarch64 GNU/Linux
> nsc@lillesand:/tmp$ unshare -m -U -r
> root@lillesand:/tmp# mount -t overlay -o rw,lowerdir=/tmp/test/lower,upperdir=/tmp/test/upper,workdir=/tmp/test/work overlay /tmp/test/merged
> root@lillesand:/tmp# rm -rf test/merged/a
> root@lillesand:/tmp# find test -ls
> 1597776 4 drwxr-xr-x 6 root root 4096 mars 3 08:24 test
> 1973978 4 drwxr-xr-x 2 root root 4096 mars 3 08:27 test/upper
> 2099881 0 c--------- 1 root root 0, 0 mars 3 08:27 test/upper/a
> 1973978 4 drwxr-xr-x 1 root root 4096 mars 3 08:27 test/merged
> 1714388 4 drwxr-xr-x 3 root root 4096 mars 3 08:24 test/lower
> 1714389 4 drwxr-xr-x 2 root root 4096 mars 3 08:27 test/lower/a
> 1714393 4 -rw-r--r-- 1 root root 86 mars 3 10:48 test/lower/a/a
> 1973979 4 drwxr-xr-x 3 root root 4096 mars 3 10:48 test/work
> 2099880 4 d--------- 2 root root 4096 mars 3 10:48 test/work/work
> root@lillesand:/tmp#
>
zsj@debian:~$ cat /sys/module/overlay/parameters/permit_mounts_in_userns
Y
zsj@debian:~/t$ mkdir -p test/lower/a test/merged test/upper test/work
zsj@debian:~/t$ uname -a | tee test/lower/a/a
Linux debian 5.10.0-3-amd64 #1 SMP Debian 5.10.13-1 (2021-02-06) x86_64 GNU/Linux
zsj@debian:~/t$ unshare -m -U -r
root@debian:~/t# mount -t overlay -o rw,lowerdir=./test/lower,upperdir=./test/upper,workdir=./test/work overlay ./test/merged/
root@debian:~/t# rm -rf ./test/merged/a
rm: cannot remove './test/merged/a': Input/output error
root@debian:~/t# find test -ls
7350352 4 drwxr-xr-x 6 root root 4096 Mar 3 22:44 test
7351341 4 drwxr-xr-x 3 root root 4096 Mar 3 22:44 test/lower
7353492 4 drwxr-xr-x 2 root root 4096 Mar 3 22:44 test/lower/a
7356441 4 -rw-r--r-- 1 root root 82 Mar 3 22:44 test/lower/a/a
7356069 4 drwxr-xr-x 3 root root 4096 Mar 3 22:45 test/work
7358324 4 d--------- 2 root root 4096 Mar 3 22:45 test/work/work
7358564 0 c--------- 2 root root 0, 0 Mar 3 22:45 test/work/work/#4
7354400 4 drwxr-xr-x 3 root root 4096 Mar 3 22:44 test/upper
7358563 4 drwxr-xr-x 2 root root 4096 Mar 3 22:45 test/upper/a
7358564 0 c--------- 2 root root 0, 0 Mar 3 22:45 test/upper/a/a
7354400 4 drwxr-xr-x 1 root root 4096 Mar 3 22:44 test/merged
7353492 4 drwxr-xr-x 1 root root 4096 Mar 3 22:45 test/merged/a
> Do you see any kernel log message from overlay fs? Might it depend on
> the underlying filesystem? Can you create a white-out char dev node
> manually?
>
[1215353.859717] Setting dangerous option permit_mounts_in_userns - tainting kernel
[1215353.859841] overlayfs: overlayfs: Allowing overlay mounts in user namespaces bears security risks
[1215425.416543] overlayfs: upper fs does not support xattr, falling back to index=off and metacopy=off.
The underlying fs is ext4.
zsj@debian:~/t$ mount|grep nvme
/dev/nvme0n1p2 on / type ext4 (rw,relatime,errors=remount-ro)
/dev/nvme0n1p4 on /home type ext4 (rw,relatime)
/dev/nvme0n1p1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
I don't know how to test "create a white-out char dev node manually".
Thanks
Reply to: