Re: [PATCH v2] unshare: Unsharing a thread does not require unsharing a vm
From: Oleg Nesterov
Date: Thu Aug 13 2015 - 12:32:48 EST
On 08/13, Eric W. Biederman wrote:
>
> Oleg Nesterov <oleg@xxxxxxxxxx> writes:
>
> > On 08/12, Eric W. Biederman wrote:
> >>
> >> + if (unshare_flags & (CLONE_SIGHAND | CLONE_VM)) {
> >> + if (atomic_read(¤t->sighand->count) > 1)
> >> + return -EINVAL;
> >> + }
> >
> > I am still not sure we want this... please the the previous email.
>
> Reading your other email I did not see why you thought this check was
> unnecessary.
>
> > But perhaps I missed something.
>
> In short:
> clone(VM) --> mm_users > 1 && sighand_struct->count == 1
> followed by:
> unshare(SIGHAND)
> the unshare should succeed.
>
> Meanwhile:
> clone(VM|SIGHAND) --> mm_users > 1 && sighand_struct->count > 1
> followed by:
> unshare(SIGHAND)
> the unshare should fail.
Yes, yes, yes.
But once again, I meant we can remove this sighand->count check
if unshare(SIGHAND) checks current_is_single_threaded(). That is
why I suggested to do
if (unshare_flags & CLONE_SIGHAND)
unshare_flags |= CLONE_VM;
in sys_unshare(), or change check_unshare_flags() to check
"unshare_flags & (CLONE_VM | CLONE_SIGHAND)" before
current_is_single_threaded().
Damn. And this discussion makes me think that another cleanup makes
sense too. Can't we move all these unshare_flags manipulations into
check_unshare_flags? So that sys_unshare() will only do
err = check_unshare_flags(&unshare_flags);
and the reader of this code won't need to read 2 functions to understand
whats going on.
Oleg.
--
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/