Re: Regression caused by commit c83ed4c9dbb3 "ubifs: Abort readdir on error"

From: Richard Weinberger
Date: Tue Oct 25 2016 - 16:10:08 EST


Peter,

On 25.10.2016 21:39, Peter Rosin wrote:
> Hi!
>
> Early on in my boot procedure I create an overlay and shuffle
> things around a bit so that the original rootfs stays readonly
> at the bottom of an overlayed readwrite fs. This way I can just
> toss out the overlayed fs and have a clean and reliable way to
> do a "factory-reset". Both the read-only root and and the overlay
> are ubifs on nand.
>
> Bisection points to commit c83ed4c9dbb3 "ubifs: Abort readdir
> on error". Reverting that commit on top of v4.9-rc2 fixes things.
>
> My "shuffle script" is as follows (with an added comment
> indicating the first point of failure) and runs as the first
> script by init.
>
> If I add a line
> ls -l /mnt || echo "ls -l /mnt failed"
> where that comment is right before the failure, I get no failure
> indication even with the broken commit, so directory traversal
> seems ok.
>
> Cheers,
> Peter
>
> #! /bin/bash
>
> test "x$1" == xstart || exit 0
>
> mkdir /tmp/log
>
> /bin/mount -o remount,rw /dev
>
> /bin/mount | /bin/grep -q "^overlay on / type overlay" && exit 0
>
> if test -e /etc/factory-reset; then
> /usr/sbin/ubiformat /dev/mtd7
> rm /etc/factory-reset
> fi
>
> /usr/sbin/ubiattach /dev/ubi_ctrl -m 7
> /usr/sbin/ubimkvol /dev/ubi1 -N ovl -m
>
> /bin/mkdir -p /mnt/ovl
> /bin/mkdir -p /mnt/roroot
> /bin/mkdir -p /mnt/merge
> /bin/mount -t ubifs /dev/ubi1_0 /mnt/ovl
>
> /bin/mkdir -p /mnt/ovl/ovl
> /bin/mkdir -p /mnt/ovl/work
> # with c83ed4c9dbb3, the following mount fails with
> # mount: mounting overlay on /mnt/merge failed: No such file or directory
> /bin/mount -t overlay -o lowerdir=/,upperdir=/mnt/ovl/ovl,workdir=/mnt/ovl/work overlay /mnt/merge

Uhhhh! Thanks for catching this.
I think I know what is going on, the fix exposes now internal UBIFS return codes to VFS.
Let me prepare a fix.

Thanks,
//richard