[RFC][PATCH 10/42] get rid of cred argument of vfs_open() and do_dentry_open()

From: Al Viro
Date: Tue Jul 10 2018 - 22:25:56 EST


From: Al Viro <viro@xxxxxxxxxxxxxxxxxx>

always equal to ->f_cred

Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
---
fs/internal.h | 2 +-
fs/namei.c | 4 ++--
fs/open.c | 15 ++++++---------
3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/fs/internal.h b/fs/internal.h
index 66473bf388e4..ab84a29f4874 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -126,7 +126,7 @@ int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
int flag);

extern int open_check_o_direct(struct file *f);
-extern int vfs_open(const struct path *, struct file *, const struct cred *);
+extern int vfs_open(const struct path *, struct file *);

/*
* inode.c
diff --git a/fs/namei.c b/fs/namei.c
index af2ec1803f57..7b1fe5e30a0d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3396,7 +3396,7 @@ static int do_last(struct nameidata *nd,
if (error)
goto out;
BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
- error = vfs_open(&nd->path, file, current_cred());
+ error = vfs_open(&nd->path, file);
if (error)
goto out;
*opened |= FILE_OPENED;
@@ -3499,7 +3499,7 @@ static int do_o_path(struct nameidata *nd, unsigned flags, struct file *file)
int error = path_lookupat(nd, flags, &path);
if (!error) {
audit_inode(nd->name, path.dentry, 0);
- error = vfs_open(&path, file, current_cred());
+ error = vfs_open(&path, file);
path_put(&path);
}
return error;
diff --git a/fs/open.c b/fs/open.c
index c0dbc67c31f1..c8fd5126c50e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -736,8 +736,7 @@ int open_check_o_direct(struct file *f)

static int do_dentry_open(struct file *f,
struct inode *inode,
- int (*open)(struct inode *, struct file *),
- const struct cred *cred)
+ int (*open)(struct inode *, struct file *))
{
static const struct file_operations empty_fops = {};
int error;
@@ -780,7 +779,7 @@ static int do_dentry_open(struct file *f,
goto cleanup_all;
}

- error = security_file_open(f, cred);
+ error = security_file_open(f, f->f_cred);
if (error)
goto cleanup_all;

@@ -858,8 +857,7 @@ int finish_open(struct file *file, struct dentry *dentry,
BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */

file->f_path.dentry = dentry;
- error = do_dentry_open(file, d_backing_inode(dentry), open,
- current_cred());
+ error = do_dentry_open(file, d_backing_inode(dentry), open);
if (!error)
*opened |= FILE_OPENED;

@@ -900,8 +898,7 @@ EXPORT_SYMBOL(file_path);
* @file: newly allocated file with f_flag initialized
* @cred: credentials to use
*/
-int vfs_open(const struct path *path, struct file *file,
- const struct cred *cred)
+int vfs_open(const struct path *path, struct file *file)
{
struct dentry *dentry = d_real(path->dentry, NULL, file->f_flags, 0);

@@ -909,7 +906,7 @@ int vfs_open(const struct path *path, struct file *file,
return PTR_ERR(dentry);

file->f_path = *path;
- return do_dentry_open(file, d_backing_inode(dentry), NULL, cred);
+ return do_dentry_open(file, d_backing_inode(dentry), NULL);
}

struct file *dentry_open(const struct path *path, int flags,
@@ -926,7 +923,7 @@ struct file *dentry_open(const struct path *path, int flags,
f = alloc_empty_file(cred);
if (!IS_ERR(f)) {
f->f_flags = flags;
- error = vfs_open(path, f, cred);
+ error = vfs_open(path, f);
if (!error) {
/* from now on we need fput() to dispose of f */
error = open_check_o_direct(f);
--
2.11.0