Subject: Re: kauth and access to process credentials
To: Bill Studenmund <email@example.com>
From: Bill Studenmund <firstname.lastname@example.org>
Date: 02/18/2007 13:55:21
Content-Type: text/plain; charset=us-ascii
On Sun, Feb 18, 2007 at 09:41:42PM +0000, David Laight wrote:
> On Sun, Feb 18, 2007 at 01:05:32PM -0800, Bill Studenmund wrote:
> > On Sun, Feb 18, 2007 at 02:10:23PM +0000, David Laight wrote:
> > > The kauth code seems to be full of wrapper functions.
> > >=20
> > > In particular every peice of code that needs to look at one of the
> > > process's uids ends up calling a function.
> > > This might be reasonable for LKMs, but for code that is linked into t=
> > > main kernel image rather OTT.
> > That's rather the point of kauth. It's supposed to be the only code are=
> > that actually knows what a credential is, so that it can change them as=
> > desired. If you want to know something, you have to ask it.
> You are allowed to ask for the uids and gids, and a lot of code (for
> compatibility reasons) has to make very specific comparisions between
> the uids and gids before doing some actions.
Like I said, the case is weaker for uid.
gid, however, I don't think you should be able to ask for. You belong to a=
set of groups, and one big complaint of our (older) code is that said set=
size was fixed. If instead you ask "is 'gid' one of my groups" then we can=
sweep everything into the kauth code.
> With the kauth scheme you have NFI whether a some syscall code is doing
> appropriate checks before doing some action - and you always require it
> to request those checks - so the kauth code cannot enforce security that
> wasn't there before.
> For an example of the code I looking at, search for pfind() in
> where it does:
> kauth_authorize_generic(pc, KAUTH_GENERIC_ISSUSER, NULL) =3D=3D 0 ||
> kauth_cred_getuid(pc) =3D=3D kauth_cred_getuid(p->p_cred) ||
> kauth_cred_geteuid(pc) =3D=3D kauth_cred_getuid(p->p_cred) ||
> kauth_cred_getuid(pc) =3D=3D kauth_cred_geteuid(p->p_cred) ||
> kauth_cred_geteuid(pc) =3D=3D kauth_cred_geteuid(p->p_cred)))
> This used to be simple structre indirecting...
I agree we can do better than that. And I thank you for pushing us towards=
The first is just read things into intermediate variables, then compare.=20
That way we make no more calls than needed.
The second thing that comes to my mind is add something akin to=20
kauth_cred_getuids(cred *, uidt *, uid *, uid *) which can return the=20
current, real, and effective uids all at once.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (NetBSD)
-----END PGP SIGNATURE-----