From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753435AbbHMQee (ORCPT ); Thu, 13 Aug 2015 12:34:34 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:59828 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752598AbbHMQec (ORCPT ); Thu, 13 Aug 2015 12:34:32 -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> <87614k73mo.fsf@x220.int.ebiederm.org> <20150813125550.GA13984@redhat.com> <87vbcjyzac.fsf@x220.int.ebiederm.org> <20150813161718.GA23114@redhat.com> Date: Thu, 13 Aug 2015 11:27:41 -0500 In-Reply-To: <20150813161718.GA23114@redhat.com> (Oleg Nesterov's message of "Thu, 13 Aug 2015 18:17:18 +0200") Message-ID: <87vbcjtapu.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//fCL27Lo0DLazJkDZ49Bqnjitg8m8a2s= 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.0 TVD_RCVD_IP Message was received from an IP address * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 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 * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.5 XM_Body_Dirty_Words Contains a dirty word * 1.0 T_XMDrugObfuBody_08 obfuscated drug references X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 376 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 4.2 (1.1%), b_tie_ro: 3.1 (0.8%), parse: 0.78 (0.2%), extract_message_metadata: 3.4 (0.9%), get_uri_detail_list: 1.68 (0.4%), tests_pri_-1000: 4.2 (1.1%), tests_pri_-950: 1.30 (0.3%), tests_pri_-900: 1.14 (0.3%), tests_pri_-400: 23 (6.2%), check_bayes: 22 (5.9%), b_tokenize: 7 (1.8%), b_tok_get_all: 8 (2.0%), b_comp_prob: 2.2 (0.6%), b_tok_touch_all: 3.0 (0.8%), b_finish: 0.66 (0.2%), tests_pri_0: 324 (86.2%), tests_pri_500: 4.1 (1.1%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 1/2] 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 in02.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: >> The only way killing CLONE_SIGHAND would be viable would be with a >> config option. There are entire generations of linux where libpthreads >> used this before CLONE_THREAD was implemented. Now perhaps no one cares >> anymore, but there are a lot of historic binairies that used it, even to >> the point where I know of at least one user outside of glibc's pthread >> implementation. > > Heh. so we still need to keep it. Thanks. Pretty much. It is possible to make this stuff go away when people stop caring but it is a long process. I think I have almost killed sys_sysctl. It seems to be disabled in most distributions. >> Yes. A shared sighand_struct will have a shared ->mm. But a private >> sighand_struct with count == 1 may also have a shared ->mm. > > Yes sure. This just means that we can check current_is_single_threaded() > if CLONE_SIGHAND | CLONE_VM, signal->count check can be avoided. As I pointed out in my follow we really can't because there is a case where mm_users > 1 and sighand_count == 1. In which case using current_is_single_threaded can cause unshare(SIGHAND) to fail. >> So while I agree with you that the sighand->count could suffer a similar >> fate as mm_users it does not. > > Ignoring the out-of-tree code ;) > > Nevermind, I won't really argue, this all is mostly cosmetic. And perhaps > this sighand->count check in check_unshare_flags() makes this code look > a bit better / more understandable. > > Still. How about the trivial *-fix.patch for -mm which simply does > > - if (unshare_flags & (CLONE_SIGHAND | CLONE_VM)) { > + if (unshare_flags & CLONE_SIGHAND) { > if (atomic_read(¤t->sighand->count) > 1) > return -EINVAL; > } > > again, this doesn't really matter. To this "| CLONE_VM" looks > very confusing to me. Definitely cosmetic. This was my preserving of your flattened test argument in around mm_users > 1 in check_unshare_flags(). It is unncessary given that we add CLONE_SIGHAND when CLONE_VM. But to have a private mm_struct you definitely need a sighand_struct. In the sense of document when these tests apply I think it makes a teensy bit of sense to have the CLONE_VM there. But if you want to send me a cosmetic patch that removes that I will add it to my tree, with the other two patches. Eric