Welcome to the Linux Foundation Forum!

LFS253 - Lab 2.5 OverlayFS UB

I've been following the lab work pretty directly, but a fairly glaring claim in 2.5 was exhibited as I did -- near the end of the lab, it directs us to add a conflicting file into the underlying lower/ and upper/ stores, "common.txt", and observe what happens. It points to the upper/ copy being the one that shadows the lower copy, presumably trying to further enforce the nature of file shadowing, etc... however, doing it in this way is, from what I can tell from the OverlayFS kernel documentation, undefined behavior. The underlying stores being modified post-mount is not going to produce predictable results, and in fact, this produced the opposite result on my machine. Re-mounting triggered the "expected" result, but for one reason or another, the filesystem cached the lower branch copy first in the moment, resulting in some fairly direct confusion for a student, since it's the exact opposite of what the lab is trying to demonstrate:

student@k8s01:~$ cat overlay/merged/common.txt
Common file from lower branch RO
student@k8s01:~$ cat overlay/lower/common.txt
Common file from lower branch RO
student@k8s01:~$ cat overlay/upper/common.txt
Common file from upper branch RW
student@k8s01:~$ cat overlay/merged/common.txt
Common file from lower branch RO
student@k8s01:~$ sudo umount overlay/merged
[sudo] password for student:
student@k8s01:~$ sudo mount -t overlay overlay -o lowerdir=overlay/lower,upperdir=overlay/upper,workdir=overlay/work overlay/merged
student@k8s01:~$ cat overlay/merged/common.txt
Common file from upper branch RW

At the end of the day, I think I have a decent grasp of things, but I'd recommend figuring out a different way of demonstrating the principles involved.

Categories

Upcoming Training