From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Lieb Subject: Re: Re: Re: Re: Re: [PATCH 1/3] switch_creds: Syscall to switch creds for file server ops Date: Fri, 1 Nov 2013 08:49:12 -0700 Message-ID: <3320616.dLyWU2ChR5@jlieb-e6410> References: <1381960919-4542-1-git-send-email-jlieb@panasas.com> <1397707.n4PsIJcfRu@jlieb-e6410> <201311012224.CBG18210.StOOMLHVJOFQFF@I-love.SAKURA.ne.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: , , , , , , , To: Tetsuo Handa Return-path: In-Reply-To: <201311012224.CBG18210.StOOMLHVJOFQFF@I-love.SAKURA.ne.jp> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Friday, November 01, 2013 22:24:12 Tetsuo Handa wrote: > Jim Lieb wrote: > > Subsequent uses look like: > > use_creds(cached fd); > >=20 > > followed by > >=20 > > open/creat/mknod/write > >=20 > > followed by > >=20 > > use_creds(-1); >=20 > Are you aware that calling commit_creds() is prohibitted between > override_creds() and revert_creds() ? >=20 > If the caller does some operation that calls commit_creds() (like > example below), the kernel triggers BUG(). Yes, I do. I caught this in an early pass. I only use override_creds(= ) and=20 revert_creds(). =20 >=20 > ---------- example module start ---------- > #include > #include > #include > #include >=20 > static int __init test_init(void) > { > { /* switch_creds() syscall */ > struct fd f =3D fdget(0); > if (!f.file) > return -EBADF; > put_cred(override_creds(f.file->f_cred)); > fdput(f); > } > { /* something that calls commit_creds() */ > struct cred *cred =3D prepare_creds(); > if (cred) > commit_creds(cred); > } > return 0; > } >=20 > static void test_exit(void) > { > } >=20 > module_init(test_init); > module_exit(test_exit); > MODULE_LICENSE("GPL"); > ---------- example module end ---------- >=20 > Since nobody can guarantee that the caller of switch_creds() never do= es > some operation that calls commit_creds(), I don't think switch_creds(= ) > based on override_creds() will work. --=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