New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues with mountpoint handling #712
Conversation
Set the essential_mounted flag before trying to mount the essential mountpoints. Then if an exception is raised, umountall_essential() will be called. Remove a redundant initialization of essential_mounts.
In util-linux versions before 2.33, the mount program does not make new bind-mounts recursive when the propagation is specified in the same command (rhbz#1584443). This affects RHEL 7 and 8. Instead, make the bind-mount first, then remount it to change mount options and/or propagation. This is the "classic" method described in the mount(8) man page, which explains that userspace must issue separate system calls, even if the options are provided in a single command. Use this method for all bind-mounts. Also, adjust the return value from this method when the bind-mount is already mounted, for consistency.
Can you please describe how to reproduce the issue you are fixing with the second patch? |
I mean, I definitely tested the code on EL7 and EL8. It would be nice to have a reproducer in the testsuite. |
The first patch looks good, btw., thank you for the PR! |
FTR, there's also 34fe0d5. I can see that split into two separate mount options was later suggested in rhbz#1815534... |
On a clean installation of CentOS 8.3, these are the mounts in the host:
Notice all of the submounts that are underneath /sys and /proc. But mock fails to perform a recursive bind-mount:
Now apply the second patch in this PR:
and then mock will do the recursive bind-mount:
|
Thanks, is this causing any real issues? Build failures? |
If mock does not undo its mounts correctly, then they are left behind when it exits. At that point, it is not possible to run mock again on the same chroot without manually removing those mounts (as the root user). As far as recursive bind mounting, I noticed this while examining the code, not directly because of something I encountered during a build. But, the function does not work as expected (it's a bug); it will produce different behavior when the host is Fedora vs. RHEL, and we do have an easy well-known fix here (which might be considered better: one system call per command). Since this is a generic function, we may use it in the future to perform recursive bind-mounts aside from /proc and /sys. It would be nice to expose the |
Yeah, I agree - I'm asking for a reproducer so I can create a new test-case. But I think it is fair if we go without the test here... |
Thank you! |
Ok, reading the manual page once more, I'm afraid the second patch was wrong - at least from recursive bind-mount perspective. Per mount(8) manual page:
From just |
It's saying that mount options can't be applied recursively at all — even with This is a separate problem that I had described in #713. |
I mean - I am reading the PR commit over again, and it talks about recursive bind-mounts; |
Mount propagation options (such as In a working version of util-linux, this command:
does exactly the same thing as:
Either method will cause the same two system calls to be issued. It will make The problem here was that there were non-working versions of util-linux, which did not correctly parse |
These fixes ensure that essential mountpoints are unmounted, in the event an exception is raised while one of them is being mounted. They also work around a known issue with util-linux versions before 2.33 (in RHEL 7 and 8) that affects recursive bind-mounting when the propagation is specified.