From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Lieb Subject: Re: Re: Re: Re: Re: Re: [PATCH 1/3] switch_creds: Syscall to switch creds for file server ops Date: Fri, 1 Nov 2013 10:16:16 -0700 Message-ID: <3147223.fCkNs1sjAc@jlieb-e6410> References: <1381960919-4542-1-git-send-email-jlieb@panasas.com> <3320616.dLyWU2ChR5@jlieb-e6410> <201311020107.FDJ87003.SHJFMOOOtLVFQF@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: <201311020107.FDJ87003.SHJFMOOOtLVFQF@I-love.SAKURA.ne.jp> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Saturday, November 02, 2013 01:07:59 Tetsuo Handa wrote: > Jim Lieb wrote: > > 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(). > >=20 > > Yes, I do. I caught this in an early pass. I only use override_cr= eds() > > and revert_creds(). >=20 > Excuse me, but even below example will trigger BUG(). You pack > override_creds() + open() + revert_creds() into one system call so th= at the > caller of this system call shall not do something that calls commit_c= reds() > ? Ok, I see your point here. If I do a switch_creds and the userland doe= s=20 something like seteuid before I do the revert, we are toast. Correct? This is an issue. Thanks for pointing this out. It is certainly not i= n my=20 use case but that doesn't mean someone else won't try it. I have some = more=20 work to do. >=20 > ---------- example module start ---------- > #include > #include > #include > #include >=20 > static int __init test_init(void) > { > const struct cred *orig; > { /* switch_cred() syscall */ > struct fd f =3D fdget(0); > if (!f.file) > return -EBADF; > orig =3D override_creds(f.file->f_cred); > fdput(f); > } > { /* something that calls commit_creds() */ > struct cred *cred =3D prepare_creds(); > if (cred) > commit_creds(cred); > } > { /* restore */ > revert_creds(orig); > } > return 0; > } >=20 > static void test_exit(void) > { > } >=20 > module_init(test_init); > module_exit(test_exit); > MODULE_LICENSE("GPL"); > ---------- example module end ---------- --=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