[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200731152736.GP23808@casper.infradead.org>
Date: Fri, 31 Jul 2020 16:27:36 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Steven Sistare <steven.sistare@...cle.com>
Cc: "Eric W. Biederman" <ebiederm@...ssion.com>,
Anthony Yznaga <anthony.yznaga@...cle.com>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org, linux-arch@...r.kernel.org, mhocko@...nel.org,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
hpa@...or.com, viro@...iv.linux.org.uk, akpm@...ux-foundation.org,
arnd@...db.de, keescook@...omium.org, gerg@...ux-m68k.org,
ktkhai@...tuozzo.com, christian.brauner@...ntu.com,
peterz@...radead.org, esyr@...hat.com, jgg@...pe.ca,
christian@...lner.me, areber@...hat.com, cyphar@...har.com
Subject: Re: [RFC PATCH 0/5] madvise MADV_DOEXEC
On Fri, Jul 31, 2020 at 10:57:44AM -0400, Steven Sistare wrote:
> Matthews sileby/mshare proposal has the same issue. If a process opts-in
> and mmap's an address in the shared region, then content becomes mapped at
> a VA that was known to the pre-fork or pre-exec process. Trust must still
> be established.
It's up to the recipient whether they try to map it at the same address
or at a fresh address. The intended use case is a "semi-shared" address
space between two processes (ie partway between a threaded, fully-shared
address space and a forked un-shared address space), in which case
there's a certain amount of trust and cooperation between the processes.
Your preservation-across-exec use-case might or might not need the
VMA to be mapped at the same address. I don't know whether qemu stores
pointers in this VMA which are absolute within the qemu address space.
If it's just the emulated process's address space, then everything will
be absolute within its own address space and everything will be opaque
to qemu. If qemu is storing its own pointers in it, then it has to be
mapped at the same address.
> > Here is another suggestion.
> >
> > Have a very simple program that does:
> >
> > for (;;) {
> > handle = dlopen("/my/real/program");
> > real_main = dlsym(handle, "main");
> > real_main(argc, argv, envp);
> > dlclose(handle);
> > }
> >
> > With whatever obvious adjustments are needed to fit your usecase.
> >
> > That should give the same level of functionality, be portable to all
> > unices, and not require you to duplicate code. It belive it limits you
> > to not upgrading libc, or librt but that is a comparatively small
> > limitation.
> >
> >
> > Given that in general the interesting work is done in userspace and that
> > userspace has provided an interface for reusing that work already.
> > I don't see the justification for adding anything to exec at this point.
>
> Thanks for the suggestion. That is clever, and would make a fun project,
> but I would not trust it for production. These few lines are just
> the first of many that it would take to reset the environment to the
> well-defined post-exec initial conditions that all executables expect,
> and incrementally tearing down state will be prone to bugs. Getting a
> clean slate from a kernel exec is a much more reliable design. The use
> case is creating long-lived apps that never go down, and the simplest
> implementation will have the fewest bugs and is the best. MADV_DOEXEC is
> simple, and does not even require a new system call, and the kernel already
> knows how to exec without bugs.
It's a net increase of 200 lines of kernel code. If 4 lines of userspace
code removes 200 lines of kernel code, I think I know which I prefer ...
Powered by blists - more mailing lists