Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756043AbcJ1Er5 (ORCPT ); Fri, 28 Oct 2016 00:47:57 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:45560 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751967AbcJ1Erz (ORCPT ); Fri, 28 Oct 2016 00:47:55 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Cyrill Gorcunov Cc: Kees Cook , Andrey Vagin , LKML , Pavel Emelyanov , Linux Containers , Jann Horn References: <20161024105959.GQ1847@uranus.lan> <8760oh8tbp.fsf@xmission.com> <20161024202925.GS1847@uranus.lan> <8760oh737b.fsf@xmission.com> <20161025090213.GX1847@uranus.lan> <87d1ilrdmt.fsf_-_@xmission.com> <20161027213918.GA1922@uranus.lan> <20161027223430.GC1922@uranus.lan> <8760odnrf5.fsf@xmission.com> Date: Thu, 27 Oct 2016 23:45:37 -0500 In-Reply-To: <8760odnrf5.fsf@xmission.com> (Eric W. Biederman's message of "Thu, 27 Oct 2016 21:22:38 -0500") Message-ID: <87pomlm68e.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=1bzz56-00047d-Ig;;;mid=<87pomlm68e.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=75.170.125.99;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+rgWff0JqN4tEzAcIoqz+Q2thOUqWLnck= X-SA-Exim-Connect-IP: 75.170.125.99 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 TR_Symld_Words too many words that have symbols inside * 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 * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.1 XMSolicitRefs_0 Weightloss drug X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Cyrill Gorcunov X-Spam-Relay-Country: X-Spam-Timing: total 759 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 3.2 (0.4%), b_tie_ro: 2.3 (0.3%), parse: 0.76 (0.1%), extract_message_metadata: 16 (2.1%), get_uri_detail_list: 1.87 (0.2%), tests_pri_-1000: 7 (1.0%), tests_pri_-950: 1.14 (0.1%), tests_pri_-900: 0.96 (0.1%), tests_pri_-400: 24 (3.2%), check_bayes: 23 (3.1%), b_tokenize: 7 (1.0%), b_tok_get_all: 8 (1.1%), b_comp_prob: 2.4 (0.3%), b_tok_touch_all: 3.1 (0.4%), b_finish: 0.61 (0.1%), tests_pri_0: 187 (24.6%), check_dkim_signature: 0.50 (0.1%), check_dkim_adsp: 3.1 (0.4%), tests_pri_500: 516 (68.0%), poll_dns_idle: 509 (67.0%), rewrite_mail: 0.00 (0.0%) Subject: Re: [REVIEW][PATCH v2] mm: Add a user_ns owner to mm_struct and fix ptrace permission checks 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 in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2532 Lines: 68 ebiederm@xmission.com (Eric W. Biederman) writes: > Cyrill Gorcunov writes: > >> On Fri, Oct 28, 2016 at 12:39:18AM +0300, Cyrill Gorcunov wrote: >>> On Thu, Oct 27, 2016 at 10:54:34AM -0500, Eric W. Biederman wrote: >>> > >>> > >>> > I can't imagine either of these changes making a practical difference >>> > to anyone but I am calling them out in case someone can. >>> > >>> > include/linux/mm_types.h | 1 + >>> > kernel/fork.c | 9 ++++++--- >>> > kernel/ptrace.c | 26 +++++++++++--------------- >>> > mm/init-mm.c | 2 ++ >>> > 4 files changed, 20 insertions(+), 18 deletions(-) >>> >>> Thanks a huge, Eric! And really sorry for delay in response, >>> I managed to miss this quite important mail for me in mail >>> storm. Gonna test it and will write you the results. Overall looks >>> great, but better be sure and run the tests. >>> >>> Reviewed-by: Cyrill Gorcunov >> >> Eric, on which kernel the patch is on top of? >> It doesn't apply on linux-next for some reason. >> >> | Date: Thu Oct 27 14:21:59 2016 +1100 >> | >> | Add linux-next specific files for 20161027 >> | >> | Signed-off-by: Stephen Rothwell >> >> I applied it on Linus' master and tests passed fine >> (but they were passing fine even without the patch, >> only linux-next failed). > > Odd. I don't think I have taken the old version out of > linux-next yet. So you can probably revert the old version out of > linux-next and apply this one. All of my development at this point is > against v4.9-rc1. > > I suspect you will find my last version on top of against v4.9-rc1 will > pass. Since my tree is only one deep and I don't think anyone except > linux-next is based on it, I plan to drop and readd this patch. > Especially since it is candidate for backporting. Mind if I add your tested-by? To see Linus's tree fail with my patch you can apply the patch below. That is the essence of what I changed to fix things. Just ignoring dumpable when an mm exists. Eric diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 44a25a1e6e83..b53983ee3f03 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -272,7 +272,7 @@ static int __ptrace_may_access(struct task_struct *task, unsigned int mode) ok: rcu_read_unlock(); mm = task->mm; - if (mm && + if (!mm || ((get_dumpable(mm) != SUID_DUMP_USER) && !ptrace_has_cap(mm->user_ns, mode))) return -EPERM;