-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
mount -o remount fails with EINVAL on kernel version 5.12.0 #2283
Comments
Given that 5.12.0 has not received bugfixes for quite some time, this could already be fixed in still maintained kernels. |
That seems likely, given that it worked on 5.19 (admittedly, I haven't tested on vanilla 5.19, but happy to try that too) What is the mount command's backwards compatibility goal here? It is currently not backwards compatible, which is fine if that is the intent, but based on the changelog, I got the impression that the intent was to be backwards compatible:
Is that only referring to the new syscall existing at all vs. being buggy? What if all mounting was broken on 5.12 not just remount? FWIW, on systems that mount a read only rootfs in an initrd then remount it rw before switch_root, no remount is as bad as no mount. |
The problem here is that the bug could be either in 5.12 or util-linux. TLDR: if it's possible to properly handle it can be done, but somebody probably has to bring up the time to do so. |
I honestly don't see why it matters where the bug is. Either the mount command is backwards compatible with 5.12.0 or it isn't. It's advertised as seeking to be, but there is a totally valid and documented behavior (-o remount) which used to work and no longer works with the new version. That's not backward compatible, regardless of which end of the API is not upholding its specification. I have a good enough reproducer that I can probably bisect/pull patches related to this stuff until it starts working like 5.19 (or 5.15.114 which is an LTS kernel that I also tested and did not reproduce). But if that's the recommendation for me, I think util-linux should be honest about backwards compatibility of the mount command w.r.t. kernel version. Alternatively, would you accept a patch along the lines of an attempted fallback to |
It does not say that it is compatible with the 5.12 mount API. We don't know if the issue is in util-linux or if the new API was broken in 5.12 and has been fixed in the meantime.
(I'm not the maintainer, so I can't accept patches or give you definitive answers) Those patches would most likely be accepted. |
Maybe it's useful to have an environment variable or mount flag to force the old mount logic so users can work around any issues until proper fixes have been implemented. |
There is also possible to add a condition when the new API will be ignored; we already use it for btrfs+selinux. In the worst case, we can use |
I'll play with it on Monday. |
Thanks for both of your help. Please let me know if I can help with implementing or testing anything. Apologies in advance for a bit of pedantry here, but I do think it is important to be clear about issues like backwards compatibility.
The changelog, and I do not think I am mangling the context or meaning:
Again, thank you for your help, and have a lovely weekend. |
Update: I believe I have found the issue. The mount_setattr syscall was failing on the check of the validity of the attr_set and attr_clr variables coming in from userspace. ATTR_NOSYMFOLLOW was present in the attributes passed in, but not in the valid list on 5.12.0 https://lore.kernel.org/linux-fsdevel/20210601135515.126639-1-brauner@kernel.org/ Adds it to the kernel's list of valid attrs, and cherry-picking that kernel change fixes the issue. I'm not sure if that information is useful for a workaround. Perhaps it would be possible to not emit that attr on kernels before that patch? |
It seems mount_setattr() is supported on Linux 5.12, but it's without MOUNT_ATTR_NOSYMFOLLOW. That's problem for remount where we reset all VFS flags. The most simple (but not elegant) is to check for kernel version and fallback to mount(2) on remount. Addresses: util-linux#2283 Signed-off-by: Karel Zak <kzak@redhat.com>
It seems mount_setattr() is supported on Linux < 5.14, but it's without MOUNT_ATTR_NOSYMFOLLOW. That's problem for remount where we reset all VFS flags. The most simple (but not elegant) is to check for kernel version and fallback to mount(2) on remount. Addresses: util-linux#2283 Signed-off-by: Karel Zak <kzak@redhat.com>
Let's introduce a stable workaround for use cases where new kernel API is not ready to use. The patch does not use "goto enosys" to exit as nothing in the hookset is initialized yet. Addresses: util-linux#1992 Addresses: util-linux#2283 Signed-off-by: Karel Zak <kzak@redhat.com>
Let's introduce a stable workaround for use cases where new kernel API is not ready to use. The patch does not use "goto enosys" to exit as nothing in the hookset is initialized yet. Addresses: util-linux#1992 Addresses: util-linux#2283 Signed-off-by: Karel Zak <kzak@redhat.com>
I have updated the patch, which now requires LIBMOUNT_FORCE_MOUNT2=always (rather than "yes"). |
It seems mount_setattr() is supported on Linux < 5.14, but it's without MOUNT_ATTR_NOSYMFOLLOW. That's problem for remount where we reset all VFS flags. The most simple (but not elegant) is to check for kernel version and fallback to mount(2) on remount. Addresses: #2283 Signed-off-by: Karel Zak <kzak@redhat.com>
As far as I can tell, any kind of invocation of
mount -o remount
fails (regardless of ro/rw/other options, or ext4/btrfs)The error output on the command line is:
Nothing interesting in dmesg, though.
To reproduce:
I built a vanilla 5.12.0 kernel off the v5.12 tag in Linus's tree, and checked out and built util-linux from source.
Sample reproducer script using loop devices and ext4 here: https://pastebin.com/mt0RcYrF
You can invoke it like this:
MOUNT_CMD=<path-to-freshly-built-mount> ./repro.sh
with
MOUNT_CMD
unset, it will usemount
and find it in$PATH
.Some more details:
I also tested it on a branch derived from 5.19 and that succeeded.
When using btrfs, bpftrace shows that we call
btrfs_remount
and that returns 0.strace shows that the syscall returning EINVAL is
mount_setattr
hacking up the mount command to always use the fallback to the old syscall also "fixes" the issue. (hack patch: https://pastebin.com/VBCd7srR)
The text was updated successfully, but these errors were encountered: