Commit 6de37b6d authored by Al Viro's avatar Al Viro

pass creds to get_empty_filp(), make sure dentry_open() passes the right creds

... and rename get_empty_filp() to alloc_empty_file().

dentry_open() gets creds as argument, but the only thing that sees those is
security_file_open() - file->f_cred still ends up with current_cred().  For
almost all callers it's the same thing, but there are several broken cases.
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c9c554f2
...@@ -101,9 +101,8 @@ int proc_nr_files(struct ctl_table *table, int write, ...@@ -101,9 +101,8 @@ int proc_nr_files(struct ctl_table *table, int write,
* done, you will imbalance int the mount's writer count * done, you will imbalance int the mount's writer count
* and a warning at __fput() time. * and a warning at __fput() time.
*/ */
struct file *get_empty_filp(void) struct file *alloc_empty_file(const struct cred *cred)
{ {
const struct cred *cred = current_cred();
static long old_max; static long old_max;
struct file *f; struct file *f;
int error; int error;
...@@ -161,7 +160,7 @@ struct file *alloc_file(const struct path *path, int flags, ...@@ -161,7 +160,7 @@ struct file *alloc_file(const struct path *path, int flags,
{ {
struct file *file; struct file *file;
file = get_empty_filp(); file = alloc_empty_file(current_cred());
if (IS_ERR(file)) if (IS_ERR(file))
return file; return file;
......
...@@ -93,7 +93,7 @@ extern void chroot_fs_refs(const struct path *, const struct path *); ...@@ -93,7 +93,7 @@ extern void chroot_fs_refs(const struct path *, const struct path *);
/* /*
* file_table.c * file_table.c
*/ */
extern struct file *get_empty_filp(void); extern struct file *alloc_empty_file(const struct cred *);
/* /*
* super.c * super.c
......
...@@ -3513,7 +3513,7 @@ static struct file *path_openat(struct nameidata *nd, ...@@ -3513,7 +3513,7 @@ static struct file *path_openat(struct nameidata *nd,
int opened = 0; int opened = 0;
int error; int error;
file = get_empty_filp(); file = alloc_empty_file(current_cred());
if (IS_ERR(file)) if (IS_ERR(file))
return file; return file;
......
...@@ -921,7 +921,7 @@ struct file *dentry_open(const struct path *path, int flags, ...@@ -921,7 +921,7 @@ struct file *dentry_open(const struct path *path, int flags,
/* We must always pass in a valid mount pointer. */ /* We must always pass in a valid mount pointer. */
BUG_ON(!path->mnt); BUG_ON(!path->mnt);
f = get_empty_filp(); f = alloc_empty_file(cred);
if (!IS_ERR(f)) { if (!IS_ERR(f)) {
f->f_flags = flags; f->f_flags = flags;
error = vfs_open(path, f, cred); error = vfs_open(path, f, cred);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment