Re: [PATCH 4/5] sulogin: mount temporary /dev and /proc if not found

Dave Reisner
2012-12-23T04:33:42Z

On Tue, Dec 18, 2012 at 04:23:11PM +0100, Karel Zak wrote:
> On Mon, Dec 10, 2012 at 01:27:10PM +0100, Werner Fink wrote:
> > configure.ac | 10 +++++++++
> > lib/consoles.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 76 insertions(+)
>
> Note that I have applied this (fixed) version of the patch.
>
> Karel
>

This is pretty broken. Using the constructor and destructor attributes
means that ANY programs linking in the code will invoke these functions.
As it's not a direct inclusion, but part of a libtool convenience lib,
the effect is pretty severe:

$ git grep -F libcommon.la | wc -l
78

This includes things such as libblkid and libmount, among others.

It wouldn't generally matter (though I'm still in favor of finding
another solution for this), but this breaks early userspace pretty hard.
Invoking mount (or even findmnt) will preemptively run this code. I'm
not clear on why, but the filesystems were NOT umounted by the
destructor, and my busybox umount as well as util-linux's switch_root
simply failed with EINVAL.

I suggest that this code be relegated to sulogin.

d