Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2620660imm; Mon, 16 Jul 2018 11:03:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf7zXVKLVJvYnt9U043eJW3pHlIPLlY8uYOxZThWOuzBpdI91ASC2g8A2x7v/S2F8Hoa700 X-Received: by 2002:a63:2ec3:: with SMTP id u186-v6mr2467363pgu.225.1531764210058; Mon, 16 Jul 2018 11:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531764210; cv=none; d=google.com; s=arc-20160816; b=lIr4/Z5aCn6lq1KDw62lmTpcamBgr9dIbsq6bViCUCCktznkkhPBE9AgwCOMxlx1Hh hY7LdH4HuglCW+mJzbvZB6iEV/saHX/9MEiGDkzN+3VB/gEyMkXPRmlJBWKKoKI/C37p KCiMNpp7RvMsajuZEAOkQt1MXntPQrDrK1kYYn8AUsfxBjnnrF+a6oyq3V+52qJqWPnW aPsdgLnYaUpoOXZylEowZtYwpYD7mheiOY15RcThipNhxg3PCi5i4mD+Z8+CxApRQwWn XzNCc/u1dt7OBZLsGoKusdeUoB+KMB0S4i+Yri8k+N69QvPZGLaYeJiaG12+9potY/sI 5ZTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=lcUvdBz7cYgLY49s9DQzPnK4jUFeFOd0Wn5rBulOsIY=; b=xzWqHsuhqRBgMDAdFSQbu4IMXwk7Q/PSOSUutItfVdLY85CkSrpZy8MaV6vwv+tHSv ArZqsTntmIBl7Ye+YACFbvZ/Cb79ELHVBLEfBV+pQ2qm1MlMc5bQ5ro7fhpRILByGW68 xnlbYFA9/lV/eO3Yvztfp8TsB5x7YGztn7C0vGL5KZmYrDSbqqAuCgBg8nQjJngLehkK XddINjQ3E6T2VkrN8a8Z1U9h6a9coMblkg4wbUB5IGK6VXXK0tR93l+XT6ShCwZ3mML5 iSplZuuRj7KUBJu5Lwquw7KKKXvaVikYm7NYAa3f70AxpVNf5K3wx3aHRrG6Bli56HxY J6SA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w15-v6si29641076plp.7.2018.07.16.11.03.14; Mon, 16 Jul 2018 11:03:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728412AbeGPSaw (ORCPT + 99 others); Mon, 16 Jul 2018 14:30:52 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:46490 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727809AbeGPSaw (ORCPT ); Mon, 16 Jul 2018 14:30:52 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1ff7pD-00051t-Hw; Mon, 16 Jul 2018 12:02:19 -0600 Received: from [97.119.167.31] (helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1ff7oy-000732-3K; Mon, 16 Jul 2018 12:02:19 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Linus Torvalds Cc: Oleg Nesterov , Andrew Morton , Linux Kernel Mailing List , Wen Yang , majiang References: <877em2jxyr.fsf_-_@xmission.com> <20180711024459.10654-7-ebiederm@xmission.com> <20180716125144.GA18262@redhat.com> <8736wjtetv.fsf@xmission.com> Date: Mon, 16 Jul 2018 13:01:59 -0500 In-Reply-To: (Linus Torvalds's message of "Mon, 16 Jul 2018 10:17:26 -0700") Message-ID: <87bmb7oy94.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1ff7oy-000732-3K;;;mid=<87bmb7oy94.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.119.167.31;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/7fb+d7dnoukApfanCMrxTzUhukHVgjZE= X-SA-Exim-Connect-IP: 97.119.167.31 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa07.xmission.com X-Spam-Level: **** X-Spam-Status: No, score=4.6 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TR_Symld_Words,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01, T_XMDrugObfuBody_04,XMNoVowels,XMSolicitRefs_0,XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 1.5 TR_Symld_Words too many words that have symbols inside * 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 * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 1.0 T_XMDrugObfuBody_04 obfuscated drug references * 0.1 XMSolicitRefs_0 Weightloss drug X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 15035 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 2.8 (0.0%), b_tie_ro: 1.78 (0.0%), parse: 1.25 (0.0%), extract_message_metadata: 21 (0.1%), get_uri_detail_list: 3.3 (0.0%), tests_pri_-1000: 4.4 (0.0%), tests_pri_-950: 1.68 (0.0%), tests_pri_-900: 1.36 (0.0%), tests_pri_-400: 32 (0.2%), check_bayes: 31 (0.2%), b_tokenize: 13 (0.1%), b_tok_get_all: 10 (0.1%), b_comp_prob: 3.6 (0.0%), b_tok_touch_all: 2.7 (0.0%), b_finish: 0.60 (0.0%), tests_pri_0: 283 (1.9%), check_dkim_signature: 0.52 (0.0%), check_dkim_adsp: 3.6 (0.0%), tests_pri_500: 14684 (97.7%), poll_dns_idle: 14673 (97.6%), rewrite_mail: 0.00 (0.0%) Subject: Re: [RFC][PATCH 07/11] signal: Deliver group signals via PIDTYPE_TGID not PIDTYPE_PID X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds writes: > On Mon, Jul 16, 2018 at 7:50 AM Eric W. Biederman wrote: >> >> In practice since glibc does not make thread id's available I don't >> expect anyone relies on this behavior. Since no one relies on it we >> can change it without creating a regression. > > Maybe. > > However, possibly not. > > The thing is, glibc wasn't the original or only use of our threads. In > fact, there are people out there that use clone() directly, without > using it for posix threading. And Oleg was right to notice this, > because the traditional model was literally to just use "kill()" on > the pid returned from clone(). I completely agree that Oleg was right to notice this, and I was definitely not right to overlook. In my description and otherwise. I also think the semantic change needs to happen in it's own separate patch so things can be tracked down. I really don't think anyone uses this but it is not smart to hold the rest of the changes hostage to my belief. So I am thinking about how to rework this. > So the semantics of Linux kill() really is to kill the thread, not the > group leader. glibc's implementation of pthreads is not the only model > out there. There are two questions. a) Can we use the pid of a thread to find the thread group? b) Will the signal be queued in the thread group? > Now, it is possible that at none of the legacy uses use CLONE_THREAD > and thus aren't affected (because tgid will always be pid). So maybe > nobody notices. That is what I expect. I don't know think legacy is a good description. Calling other uses of CLONE_THREAD non-glibc seems better. The old LinuxThreads did not use CLONE_THREAD because it did not exist. > > But we really have three different 'kill' system calls: > > - the original 'kill' system call (#37 on x86-32). > > This looks up the thread ID, but signals the *group*. > > - tkill (#238) > > This looks up the thread, and signals the specific thread. > > - tgkill (#270) > > This looks up the tgid, and signals the group. No. tgkill is a less racy version of tkill and verifies that the thread it signals is in the proper thread group. > Modern glibc will not even use the original 'kill()' at all, I think. > But it's the legacy behavior. No. Modern glibc definitely still uses kill. As kill is the only one exporting the posix kill API. > So I do think Oleg is right. We should be careful. You'll not notice > breakage on a modern distro, but you might easily break old code. Yes. We definitely need to be careful. At the same time since this isn't something the old LinuxThreads had to cope with we can probably clean it up. But as that is not my focus it should probably be pushed out. Eric