From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752578AbcAFB1B (ORCPT ); Tue, 5 Jan 2016 20:27:01 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:60669 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752258AbcAFB06 (ORCPT ); Tue, 5 Jan 2016 20:26:58 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Josh Boyer Cc: Andy Lutomirski , "Serge E. Hallyn" , Jann Horn , Roland McGrath , Oleg Nesterov , "linux-kernel\@vger.kernel.org" , "security\@kernel.org" , Serge Hallyn , Linus Torvalds References: <20151226011038.GA25455@pc.thejh.net> <1451098351-8917-1-git-send-email-jann@thejh.net> <20151226215101.GB21578@mail.hallyn.com> Date: Tue, 05 Jan 2016 19:17:19 -0600 In-Reply-To: (Josh Boyer's message of "Mon, 4 Jan 2016 10:03:45 -0500") Message-ID: <87y4c3ld5s.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX19HAvqg2gndteGUomKpZY5je1ndCglK4Zg= X-SA-Exim-Connect-IP: 97.121.81.63 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 * 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.4994] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.1 XMSolicitRefs_0 Weightloss drug X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Josh Boyer X-Spam-Relay-Country: X-Spam-Timing: total 609 ms - load_scoreonly_sql: 0.10 (0.0%), signal_user_changed: 5.0 (0.8%), b_tie_ro: 3.4 (0.6%), parse: 1.21 (0.2%), extract_message_metadata: 23 (3.7%), get_uri_detail_list: 2.9 (0.5%), tests_pri_-1000: 9 (1.6%), tests_pri_-950: 1.40 (0.2%), tests_pri_-900: 1.22 (0.2%), tests_pri_-400: 26 (4.2%), check_bayes: 25 (4.0%), b_tokenize: 7 (1.2%), b_tok_get_all: 8 (1.3%), b_comp_prob: 3.0 (0.5%), b_tok_touch_all: 3.4 (0.6%), b_finish: 0.82 (0.1%), tests_pri_0: 428 (70.3%), check_dkim_signature: 0.73 (0.1%), check_dkim_adsp: 4.0 (0.7%), tests_pri_500: 110 (18.1%), poll_dns_idle: 101 (16.6%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH] ptrace: being capable wrt a process requires mapped uids/gids 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 Josh Boyer writes: > On Sat, Dec 26, 2015 at 9:03 PM, Andy Lutomirski wrote: >> On Sat, Dec 26, 2015 at 1:51 PM, Serge E. Hallyn >> wrote: >>> On Sat, Dec 26, 2015 at 03:52:31AM +0100, Jann Horn wrote: >>>> ptrace_has_cap() checks whether the current process should be >>>> treated as having a certain capability for ptrace checks >>>> against another process. Until now, this was equivalent to >>>> has_ns_capability(current, target_ns, CAP_SYS_PTRACE). >>>> >>>> However, if a root-owned process wants to enter a user >>>> namespace for some reason without knowing who owns it and >>>> therefore can't change to the namespace owner's uid and gid >>>> before entering, as soon as it has entered the namespace, >>>> the namespace owner can attach to it via ptrace and thereby >>>> gain access to its uid and gid. >>>> >>>> While it is possible for the entering process to switch to >>>> the uid of a claimed namespace owner before entering, >>>> causing the attempt to enter to fail if the claimed uid is >>>> wrong, this doesn't solve the problem of determining an >>>> appropriate gid. >>>> >>>> With this change, the entering process can first enter the >>>> namespace and then safely inspect the namespace's >>>> properties, e.g. through /proc/self/{uid_map,gid_map}, >>>> assuming that the namespace owner doesn't have access to >>>> uid 0. >>>> >>>> Changed in v2: The caller needs to be capable in the >>>> namespace into which tcred's uids/gids can be mapped. >>>> >>>> Signed-off-by: Jann Horn >>> >>> Acked-by: Serge Hallyn >> >> Acked-by: Andy Lutomirski >> >> Who's going to apply this? Linus? Eric? > > An Ack from Oleg would be nice too. I'm guessing this got lost in the > holidays but it has an assigned CVE now. Would be good to get it in > 4.4 final. If people are going to go around and refuse to understand the problem and assign CVEs to the kernel when they can't understand what is necessary to safely write code I am inclined to nack the entire mess. Whatever (if anything) that is calling setns in this problematic way is the problem today. This thread is about a feature request to make it easier to write secure code not about a vulnerability in user namespaces. Eric