From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754391AbbHFOAm (ORCPT ); Thu, 6 Aug 2015 10:00:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34383 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752614AbbHFOAl (ORCPT ); Thu, 6 Aug 2015 10:00:41 -0400 Date: Thu, 6 Aug 2015 15:44:26 +0200 From: Oleg Nesterov To: "Eric W. Biederman" Cc: "Kirill A. Shutemov" , Andrew Morton , Kees Cook , David Howells , linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , "Kirill A. Shutemov" , Rik van Riel , Vladimir Davydov , Ricky Zhou , Julien Tinnes Subject: Re: [PATCH] user_ns: use correct check for single-threadedness Message-ID: <20150806134426.GA6843@redhat.com> References: <20150728171500.GA2871@www.outflux.net> <20150728143504.5aa996ba5955522a19c2d5f1@linux-foundation.org> <20150728221111.GA23391@node.dhcp.inet.fi> <20150805172356.GA20490@redhat.com> <87wpx9sjhq.fsf@x220.int.ebiederm.org> <87614tr2jd.fsf@x220.int.ebiederm.org> <20150806130629.GA4728@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150806130629.GA4728@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/06, Oleg Nesterov wrote: > > On 08/05, Eric W. Biederman wrote: > > > > So I have to ask. > > I hope you are asking someone else, not me ;) I never understood what > exactly we try to restrict and why. > > > Is it possible to rework these checks such that we > > look at the sighand struct and signal sharing handling sharing instead > > of the count on the mm_struct? > > Then why we can't simply check thread_group_empty() == T ? Why should we > worry about CLONE_SIGHAND at all? The same for clone() actually... I forgot why we decided to check CLONE_SIGHAND, iirc I suggested CLONE_THREAD initially then we switched to CLONE_SIGHAND "just in case", to make it as strict as possible. How about the patch below? (note that the "or parent" part of the comment is wrong in any case). Oleg. --- x/kernel/fork.c +++ x/kernel/fork.c @@ -1279,10 +1279,9 @@ static struct task_struct *copy_process( /* * If the new process will be in a different pid or user namespace - * do not allow it to share a thread group or signal handlers or - * parent with the forking task. + * do not allow it to share a thread group with the forking task. */ - if (clone_flags & CLONE_SIGHAND) { + if (clone_flags & CLONE_THREAD) { if ((clone_flags & (CLONE_NEWUSER | CLONE_NEWPID)) || (task_active_pid_ns(current) != current->nsproxy->pid_ns_for_children))