From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out03.mta.xmission.com ([166.70.13.233]:46908 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751389AbcJaEQm (ORCPT ); Mon, 31 Oct 2016 00:16:42 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Jann Horn Cc: Krister Johansen , Alexander Viro , Roland McGrath , Oleg Nesterov , John Johansen , James Morris , "Serge E. Hallyn" , Paul Moore , Stephen Smalley , Eric Paris , Casey Schaufler , Kees Cook , Andrew Morton , Janis Danisevskis , Seth Forshee , Thomas Gleixner , Benjamin LaHaise , Ben Hutchings , Andy Lutomirski , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, security@kernel.org References: <1474663238-22134-1-git-send-email-jann@thejh.net> <1474663238-22134-9-git-send-email-jann@thejh.net> <20161002031600.GC2635@templeofstupid.com> <20161030190915.GD2558@pc.thejh.net> Date: Sun, 30 Oct 2016 23:14:04 -0500 In-Reply-To: <20161030190915.GD2558@pc.thejh.net> (Jann Horn's message of "Sun, 30 Oct 2016 20:09:15 +0100") Message-ID: <87d1ih5f5f.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [PATCH v2 8/8] Documentation: add security/ptrace_checks.txt Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Jann Horn writes: > On Sat, Oct 01, 2016 at 08:16:00PM -0700, Krister Johansen wrote: >> On Fri, Sep 23, 2016 at 10:40:38PM +0200, Jann Horn wrote: >> > +===================== >> > +FILESYSTEM DEBUG APIS >> > +===================== >> > + >> > +The pid / tgid entries in procfs contain various entries that allow debugging >> > +access to a process. Interesting entries are: >> > + >> > + - auxv permits an ASLR bypass >> > + - cwd can permit bypassing filesystem restrictions in some cases >> > + - environ can leak secret tokens >> > + - fd can permit bypassing filesystem restrictions or leak access to things like >> > + pipes >> > + - maps permits an ASLR bypass >> > + - mem grants R+W access to process memory >> > + - stat permits an ASLR bypass >> > + >> > +Of these, all use both a normal filesystem DAC check (where the file owner is >> > +the process owner for a dumpable process, root for a nondumpable process) and a >> > +ptrace_may_access() check; however, the DAC check may be modified, and the >> > +ptrace_may_access() is performed under PTRACE_FSCREDS, meaning that instead of >> > +the caller's ruid, rgid and permitted capabilities, the fsuid, fsgid and >> > +effective capabilities are used, causing the case where a daemon drops its euid >> > +prior to accessing a file for the user to be treated correctly for this check. >> >> Thanks for writing this up. >> >> Is it worth mentioning some of the less obvious aspects of how user >> namespaces interact with the filesystem debug APIs? Of particular note: >> a nondumpable process will always be assigned the global root ids. >> Checks against capabilities for procfs require that the uid and gid have >> a mapping in the current namepsace. That's enforced through >> capable_wrt_inode_uidgid(). > > Yeah, makes sense. Added that. Thanks! That will actually be changing for 4.10. mm->user_ns allows me to use the user namespace id 0 if that id is mapped. Eric