unshare(CLONE_VM) Re: [PATCH] unshare: Use rcu_assign_pointer when setting sighand

From: Julian Smith
Date: Mon Mar 14 2016 - 09:58:21 EST


On Sat, 18 Mar 2006 20:24:51 +0300
Oleg Nesterov <oleg@xxxxxxxxxx> wrote:

[...]

> However, I stronly beleive unshare(CLONE_VM) is buggy.
>
> sys_unshare:
>
>
> if (new_mm) {
> ...
> new_mm = mm;
> }
>
> ...
>
> bad_unshare_cleanup_vm:
> if (new_mm)
> mmput(new_mm);
>
>
> mmput() ignores mm->core_waiters.

Apologies for re-opening a ten-year-old thread.

I'm looking into whether it would be possible to extend the unshare
syscall to support the CLONE_VM flag with multi-threaded processes,
because this would allow us at Undo to record multi-threaded user
processes much more efficiently than at present.

We currently have to serialise threads and so suffer an N-times
slowdown when recording a process with N cpu-bound threads. But if we
could get per-thread memory permissions with unshare(CLONE_VM), we'd be
able record a multi-threaded process with almost no per-thread
slowdown.

When the unshare syscall was introduced, it seems that the
mm->core_waiters issue was the only thing that prevented CLONE_VM being
supported. Is that right, or were there other problems too?

Many thanks for any information about this.

- Julian

--
http://undo-software.com