From: Jim Lieb Subject: Re: Re: [PATCH 1/3] switch_creds: Syscall to switch creds for file server ops Date: Wed, 16 Oct 2013 20:35:56 -0700 Message-ID: <12126075.0PGVvhDUvN@jlieb-e6410> References: <1381960919-4542-1-git-send-email-jlieb@panasas.com> <87ppr4lmp3.fsf@xmission.com> <20131017012050.GR13318@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: "Eric W. Biederman" , , , , , , To: Al Viro Return-path: Received: from natasha.panasas.com ([67.152.220.90]:39089 "EHLO natasha.panasas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752696Ab3JQDgO convert rfc822-to-8bit (ORCPT ); Wed, 16 Oct 2013 23:36:14 -0400 In-Reply-To: <20131017012050.GR13318@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thursday, October 17, 2013 02:20:50 Al Viro wrote: > On Wed, Oct 16, 2013 at 06:18:16PM -0700, Eric W. Biederman wrote: > > That doesn't look bad but it does need capable(CAP_SETUID) && > > capable(CAP_SETGID) or possibly something a little more refined. >=20 > D'oh >=20 > > I don't think we want file descriptor passing to all of a sudden be= come > > a grant of privilege, beyond what the passed fd can do. >=20 > Definitely. And an extra ) to make it compile wouldn't hurt either..= =2E Ok, I'll rework this, dropping the void arg etc. How about this: 1. have one arg, the fd, i.e. SYSCALL_DEFINE1(switch_cred, int, fd) 2. if the fd >=3D0 do the override in my "use the fd" variation. This = would do=20 the capability check after the valid fd check. This means that you mus= t have privs to mess with privs. Returns 0 or either EBADF or EPERM 3. if the fd =3D=3D -1 do the revert case. The reason for this is ther= e are 4=20 syscalls needed to change the creds and each has an error return. We n= eed a way to escape the damage and a revert to the real creds set is the be= st way=20 to return to a known state. This does not require a capability check b= ecause all that can happen is to return to the immutable real set. Also, I do= n't=20 need the initial open of /dev/null. Does this fit? Jim --=20 Jim Lieb Linux Systems Engineer Panasas Inc. "If ease of use was the only requirement, we would all be riding tricyc= les" - Douglas Engelbart 1925=E2=80=932013 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html