lkml.org 
[lkml]   [2013]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Re: Re: Re: [PATCH 1/3] switch_creds: Syscall to switch creds for file server ops
From
Date
Jim Lieb wrote:
> Subsequent uses look like:
>
> use_creds(cached fd);
> followed by
> open/creat/mknod/write
> followed by
> use_creds(-1);

Are you aware that calling commit_creds() is prohibitted between
override_creds() and revert_creds() ?

If the caller does some operation that calls commit_creds() (like
example below), the kernel triggers BUG().

---------- example module start ----------
#include <linux/module.h>
#include <linux/cred.h>
#include <linux/fs.h>
#include <linux/file.h>

static int __init test_init(void)
{
{ /* switch_creds() syscall */
struct fd f = 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 = prepare_creds();
if (cred)
commit_creds(cred);
}
return 0;
}

static void test_exit(void)
{
}

module_init(test_init);
module_exit(test_exit);
MODULE_LICENSE("GPL");
---------- example module end ----------

Since nobody can guarantee that the caller of switch_creds() never does
some operation that calls commit_creds(), I don't think switch_creds()
based on override_creds() will work.


\
 
 \ /
  Last update: 2013-11-01 14:41    [W:0.062 / U:0.668 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site