From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753645AbbHMQqo (ORCPT ); Thu, 13 Aug 2015 12:46:44 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:39767 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752588AbbHMQqm (ORCPT ); Thu, 13 Aug 2015 12:46:42 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov 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 References: <87wpx9sjhq.fsf@x220.int.ebiederm.org> <87614tr2jd.fsf@x220.int.ebiederm.org> <20150806130629.GA4728@redhat.com> <20150806134426.GA6843@redhat.com> <871tf9cnbi.fsf_-_@x220.int.ebiederm.org> <87vbclb8op.fsf_-_@x220.int.ebiederm.org> <20150812174847.GA6703@redhat.com> <87wpx046s6.fsf_-_@x220.int.ebiederm.org> <20150813125704.GB13984@redhat.com> <87k2szw51x.fsf@x220.int.ebiederm.org> <20150813163025.GA24027@redhat.com> Date: Thu, 13 Aug 2015 11:39:51 -0500 In-Reply-To: <20150813163025.GA24027@redhat.com> (Oleg Nesterov's message of "Thu, 13 Aug 2015 18:30:25 +0200") Message-ID: <877fozta5k.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX1/Iqc8JbyJX7GfJ7Xw4icC+j7d9ZDUiNuc= X-SA-Exim-Connect-IP: 67.3.205.173 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa01 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa01 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 577 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 3.9 (0.7%), b_tie_ro: 2.7 (0.5%), parse: 1.37 (0.2%), extract_message_metadata: 4.8 (0.8%), get_uri_detail_list: 2.3 (0.4%), tests_pri_-1000: 7 (1.2%), tests_pri_-950: 2.0 (0.4%), tests_pri_-900: 1.73 (0.3%), tests_pri_-400: 37 (6.3%), check_bayes: 35 (6.0%), b_tokenize: 12 (2.1%), b_tok_get_all: 12 (2.0%), b_comp_prob: 3.8 (0.7%), b_tok_touch_all: 3.0 (0.5%), b_finish: 0.91 (0.2%), tests_pri_0: 491 (85.1%), tests_pri_500: 7 (1.2%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH v2] unshare: Unsharing a thread does not require unsharing a vm X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov writes: > On 08/13, Eric W. Biederman wrote: >> >> Oleg Nesterov 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(). See the two cases above that change to unshare_flags will make unshare(SIGHAND) fail when sighand_struct->count == 1. Which is fundamentally wrong. > 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. Eric