Skip to content

Commit ae2bb29

Browse files
author
Al Viro
committed
get rid of cred argument of vfs_open() and do_dentry_open()
always equal to ->f_cred Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent ea73ea7 commit ae2bb29

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

‎fs/internal.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
126126
int flag);
127127

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

131131
/*
132132
* inode.c

‎fs/namei.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3396,7 +3396,7 @@ static int do_last(struct nameidata *nd,
33963396
if (error)
33973397
goto out;
33983398
BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
3399-
error = vfs_open(&nd->path, file, current_cred());
3399+
error = vfs_open(&nd->path, file);
34003400
if (error)
34013401
goto out;
34023402
*opened |= FILE_OPENED;
@@ -3499,7 +3499,7 @@ static int do_o_path(struct nameidata *nd, unsigned flags, struct file *file)
34993499
int error = path_lookupat(nd, flags, &path);
35003500
if (!error) {
35013501
audit_inode(nd->name, path.dentry, 0);
3502-
error = vfs_open(&path, file, current_cred());
3502+
error = vfs_open(&path, file);
35033503
path_put(&path);
35043504
}
35053505
return error;

‎fs/open.c‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,7 @@ int open_check_o_direct(struct file *f)
736736

737737
static int do_dentry_open(struct file *f,
738738
struct inode *inode,
739-
int (*open)(struct inode *, struct file *),
740-
const struct cred *cred)
739+
int (*open)(struct inode *, struct file *))
741740
{
742741
static const struct file_operations empty_fops = {};
743742
int error;
@@ -777,7 +776,7 @@ static int do_dentry_open(struct file *f,
777776
goto cleanup_all;
778777
}
779778

780-
error = security_file_open(f, cred);
779+
error = security_file_open(f, f->f_cred);
781780
if (error)
782781
goto cleanup_all;
783782

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

857856
file->f_path.dentry = dentry;
858-
error = do_dentry_open(file, d_backing_inode(dentry), open,
859-
current_cred());
857+
error = do_dentry_open(file, d_backing_inode(dentry), open);
860858
if (!error)
861859
*opened |= FILE_OPENED;
862860

@@ -897,16 +895,15 @@ EXPORT_SYMBOL(file_path);
897895
* @file: newly allocated file with f_flag initialized
898896
* @cred: credentials to use
899897
*/
900-
int vfs_open(const struct path *path, struct file *file,
901-
const struct cred *cred)
898+
int vfs_open(const struct path *path, struct file *file)
902899
{
903900
struct dentry *dentry = d_real(path->dentry, NULL, file->f_flags, 0);
904901

905902
if (IS_ERR(dentry))
906903
return PTR_ERR(dentry);
907904

908905
file->f_path = *path;
909-
return do_dentry_open(file, d_backing_inode(dentry), NULL, cred);
906+
return do_dentry_open(file, d_backing_inode(dentry), NULL);
910907
}
911908

912909
struct file *dentry_open(const struct path *path, int flags,
@@ -922,7 +919,7 @@ struct file *dentry_open(const struct path *path, int flags,
922919

923920
f = alloc_empty_file(flags, cred);
924921
if (!IS_ERR(f)) {
925-
error = vfs_open(path, f, cred);
922+
error = vfs_open(path, f);
926923
if (!error) {
927924
/* from now on we need fput() to dispose of f */
928925
error = open_check_o_direct(f);

0 commit comments

Comments
 (0)