Re: [PATCH] allow execve'ing "/proc/self/exe" even if /proc is notmounted
From: Al Viro
Date: Wed Jun 24 2009 - 19:59:10 EST
On Thu, Jun 25, 2009 at 01:00:56AM +0200, Denys Vlasenko wrote:
> More elegant way is to execute /proc/self/exe.
> This works just fine as long as /proc is mounted.
So mount it.
> But it breaks if /proc isn't mounted, and this can happen in real-world
> usage. For example, when shell invoked very early in initrd/initramfs.
So mount it.
> With this patch, it is possible to execute /proc/self/exe
> even if /proc is not mounted.
> How patch does it: when execve syscall discovers that opening of binary
> image fails, a small bit of code is added to special case "/proc/self/exe"
> string. If binary name is *exactly* that string, and if error is ENOENT
> or EACCES, then exec will still succeed, using current binary's image.
> Please apply.
No. This is just plain sick. Magical pathnames have no business being
in the kernel. If procfs is too much for your sensitive soul, do an
extremely trimmed-down version that would consist of *one* *file* (yes,
as root and only node on fs). Said file being a procfs-style symlink,
doing exactly what /proc/self/exec would do.
On such system you can just mkdir /proc/self, touch /proc/self/exec,
mount -t self_exec none /proc/self/exec and be done with that. No
magic needed, end of the story.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/