Repository navigation
Conversation
Passing NULL for the filename to mnt_table_parse_mtab allows libmount to pick either /etc/mtab or /proc/self/mountinfo depending on whether /etc/mtab is a regular file or not. Normally it is a symlink but when booting with an empty /etc the symlink won't be created until tmpfiles runs. Combined with 6f20f85 which re-enables writing to /etc/mtab we now have systemd reading an incomplete mount table until tmpfiles runs. Whether or not this is a problem is inherently racy but can cause mount units to be marked as dead. Later if the unit is activated it may fail. CoreOS has hit this bug a couple times over with usr.mount. Relatedly, util-linux introduced the --enable-libmount-force-mountinfo configure option as an alternative work-around for this sort of situation. Considering that option is not enabled by default and systemd should never read /etc/mtab regardless of util-linux's build config we may as well fix the bug here too. :)
|
Indeed, we assume that util-linux gets built with So, 👍 from me. [1] Not on BSD, where it builds too, despite the name :-) |
|
Well, patch is technically correct and I don't see a problem with it. But --enable-libmount-force-mountinfo forces libmount to use mountinfo also in another situations (for example in mount(8)) and you really want to use this option to be safe. We should be really strict about systemd requirements. It's naive to assume that systemd will work everywhere... So, apply the patch if you're really paranoid, but still require --enable-libmount-force-mountinfo. |
|
Note, it's possible that in v2.29 we will kill mtab support at all (or at least force to mountinfo by default), but we need discussion about it on util-linux upstream. |
|
I am tempted to say we should rather document in the README that we don't support util-linux without --enable-libmount-force-mountinfo set. It sounds weird, adding work-arounds for /etc/mtab usage to systemd, after all… |
|
I thought it's already documented :-) |
|
The patch removes one way that users can screw up systemd installation. Granted, they could have other issues if util-linux is compiled wrong, but since we "hide" those issues after tmpfiles is run, things might otherwise work just fine. It also makes reading of the code slightly easier. So +1 to merging. |
|
And note that "users can screw up" includes disros! I had no idea that util-linix option existed until this second round of hitting the same bug. Unless util-linix exposes the option in pkg-config or similar so systemd can refuse to build without it claiming systemd doesn't support util-linix builds without it isn't really helpful. When this problem comes up it is inherently racy, only might happen on the first boot of a system, happens so early during boot journal isn't running so the bad mounted->dead transition is only going to be visible in debug logging if you think to log to kmsg and configure the kernel with a huge buffer (console logging is too slow), and given pid1 keeps envoron empty and stderr redirected to devnull it takes custom hacking to enable and capture the libmount debug messages that make this bug obvious. Basically re-enbling writing mtab with the removal of '-n' from mount commands a while back has led us to spend a week debugging usr.mount twice. (The same person wasn't available to work on it both times so there was a lot of step retracing). The commit message claimed removing -n was harmless being and old and deprecated thing but until mtab support is actually removed that little -n option is actually still meaningful! :) This commit certainly doesn't eliminate other possible situations the --enable-libmount-force-mountinfo option fixes but at least those are probably not in pid1 during early boot and thus practical to debug for most people in a reasonable amount of time. Also, ugg, sorry for the close/open and truncated post of this comment earlier. Teach me to use github on my phone... |
|
Yeah, we should have documented the configure switch required for util-linux in the NEWS+README files. I am very sure we should not override library defaults in code, hence I am against the proposed patch. However, we really should document that we require the aforementioned configure switch to be set... |
|
I don't follow why a value shouldn't be specified here. Passing |
|
@poettering: you are saying that
I don't think we should be detecting broken configuration in other libraries by breaking users' systems. |
|
As the systemd maintainer on a distro that supports both systemd and other inits (Gentoo), forcing If necessary, I could control that option with a build-time USE flag, and then depend on that use flag from the systemd ebuild. That would result in users getting an error message at build/install time if their util-linux package is misconfigured. If there is a way to force the proper behavior from libmount within systemd itself, I would greatly appreciate it. |
|
Can one of the admins verify this patch? |
|
@floppym i am sorry, but my sympathies for Gentoo wanting to support /etc/mtab are pretty limited. It's a seriously broken concept, and if you want to support that, then it should be on Gentoo really, i.e. maintain that locally... @keszybz I am pretty sure we should leave the library defaults in ther by default, and not hardcode too much information, overriding its defaults. i.e. the docs already suggest that there are three possible options ("/etc/mtab or /proc/self/mountinfo + /run/mount/utabs or /proc/mounts"), and in reality I really don't want to get too much into the business of telling libmount what to do there, except that I know that /etc/mtab is something we really should not support. This is particularly relevant as specifying "/proc/self/mountinfo" is actually slightly misleading, as it also needs "/run/mount/utabs" in that case. Hence: yes, we break the abstraction that libmount is, by saying that we don't support /etc/mtab, but then again, I prefer breaking this abstraction in text only, and not in code. Or to say this differently: I think it would have been a better choice if libmount would just have switched this over internally, and we never would have had to deal with this in the systemd context, because ultimately I don't really care where libmount gets its data from, as long as it's not /etc/mtab... For example, maybe one day with get a syscall based iface to acquire the mount table. If so, I think it should really be up to libmount to use that, and we shouldn't force it to use "/proc/self/mountinfo" in that case, nor even have to think about that then. I have now added a comment about this to NEWS and README. I hope that settles the issue. |
Passing NULL for the filename to mnt_table_parse_mtab allows libmount to
pick either /etc/mtab or /proc/self/mountinfo depending on whether
/etc/mtab is a regular file or not. Normally it is a symlink but when
booting with an empty /etc the symlink won't be created until tmpfiles
runs. Combined with 6f20f85 which re-enables writing to /etc/mtab we
now have systemd reading an incomplete mount table until tmpfiles runs.
Whether or not this is a problem is inherently racy but can cause mount
units to be marked as dead. Later if the unit is activated it may fail.
CoreOS has hit this bug a couple times over with usr.mount.
Relatedly, util-linux introduced the --enable-libmount-force-mountinfo
configure option as an alternative work-around for this sort of
situation. Considering that option is not enabled by default and systemd
should never read /etc/mtab regardless of util-linux's build config we
may as well fix the bug here too. :)
Fixes #2960 coreos/bugs#1187 coreos/bugs#463