Revert "ANDROID: vfs: Add permission2 for filesystems with per mount permissions"

This reverts commit 4fd07efd90 as it is no
longer needed because sdcardfs is gone.

Bug: 157700134
Cc: Daniel Rosenberg <drosen@google.com>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Yongqin Liu <yongqin.liu@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iafecb7f5ee39c6c8828741b9c3fced68f0ca2e95
This commit is contained in:
Greg Kroah-Hartman 2020-05-28 16:44:45 +02:00
parent 972cde43ff
commit c3271fe281
11 changed files with 72 additions and 168 deletions

View File

@ -244,7 +244,7 @@ int notify_change2(struct vfsmount *mnt, struct dentry * dentry, struct iattr *
return -EPERM; return -EPERM;
if (!inode_owner_or_capable(inode)) { if (!inode_owner_or_capable(inode)) {
error = inode_permission2(mnt, inode, MAY_WRITE); error = inode_permission(inode, MAY_WRITE);
if (error) if (error)
return error; return error;
} }

View File

@ -1371,7 +1371,7 @@ EXPORT_SYMBOL(flush_old_exec);
void would_dump(struct linux_binprm *bprm, struct file *file) void would_dump(struct linux_binprm *bprm, struct file *file)
{ {
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
if (inode_permission2(file->f_path.mnt, inode, MAY_READ) < 0) { if (inode_permission(inode, MAY_READ) < 0) {
struct user_namespace *old, *user_ns; struct user_namespace *old, *user_ns;
bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP; bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP;

View File

@ -380,11 +380,9 @@ EXPORT_SYMBOL(generic_permission);
* flag in inode->i_opflags, that says "this has not special * flag in inode->i_opflags, that says "this has not special
* permission function, use the fast case". * permission function, use the fast case".
*/ */
static inline int do_inode_permission(struct vfsmount *mnt, struct inode *inode, int mask) static inline int do_inode_permission(struct inode *inode, int mask)
{ {
if (unlikely(!(inode->i_opflags & IOP_FASTPERM))) { if (unlikely(!(inode->i_opflags & IOP_FASTPERM))) {
if (likely(mnt && inode->i_op->permission2))
return inode->i_op->permission2(mnt, inode, mask);
if (likely(inode->i_op->permission)) if (likely(inode->i_op->permission))
return inode->i_op->permission(inode, mask); return inode->i_op->permission(inode, mask);
@ -417,8 +415,7 @@ static int sb_permission(struct super_block *sb, struct inode *inode, int mask)
} }
/** /**
* inode_permission2 - Check for access rights to a given inode * inode_permission - Check for access rights to a given inode
* @mnt:
* @inode: Inode to check permission on * @inode: Inode to check permission on
* @mask: Right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) * @mask: Right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
* *
@ -428,7 +425,7 @@ static int sb_permission(struct super_block *sb, struct inode *inode, int mask)
* *
* When checking for MAY_APPEND, MAY_WRITE must also be set in @mask. * When checking for MAY_APPEND, MAY_WRITE must also be set in @mask.
*/ */
int inode_permission2(struct vfsmount *mnt, struct inode *inode, int mask) int inode_permission(struct inode *inode, int mask)
{ {
int retval; int retval;
@ -452,7 +449,7 @@ int inode_permission2(struct vfsmount *mnt, struct inode *inode, int mask)
return -EACCES; return -EACCES;
} }
retval = do_inode_permission(mnt, inode, mask); retval = do_inode_permission(inode, mask);
if (retval) if (retval)
return retval; return retval;
@ -460,14 +457,7 @@ int inode_permission2(struct vfsmount *mnt, struct inode *inode, int mask)
if (retval) if (retval)
return retval; return retval;
retval = security_inode_permission(inode, mask); return security_inode_permission(inode, mask);
return retval;
}
EXPORT_SYMBOL_GPL(inode_permission2);
int inode_permission(struct inode *inode, int mask)
{
return inode_permission2(NULL, inode, mask);
} }
EXPORT_SYMBOL(inode_permission); EXPORT_SYMBOL(inode_permission);
@ -1646,13 +1636,13 @@ static struct dentry *lookup_slow(const struct qstr *name,
static inline int may_lookup(struct nameidata *nd) static inline int may_lookup(struct nameidata *nd)
{ {
if (nd->flags & LOOKUP_RCU) { if (nd->flags & LOOKUP_RCU) {
int err = inode_permission2(nd->path.mnt, nd->inode, MAY_EXEC|MAY_NOT_BLOCK); int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
if (err != -ECHILD) if (err != -ECHILD)
return err; return err;
if (unlazy_walk(nd)) if (unlazy_walk(nd))
return -ECHILD; return -ECHILD;
} }
return inode_permission2(nd->path.mnt, nd->inode, MAY_EXEC); return inode_permission(nd->inode, MAY_EXEC);
} }
static int reserve_stack(struct nameidata *nd, struct path *link, unsigned seq) static int reserve_stack(struct nameidata *nd, struct path *link, unsigned seq)
@ -2554,8 +2544,8 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
} }
EXPORT_SYMBOL(vfs_path_lookup); EXPORT_SYMBOL(vfs_path_lookup);
static int lookup_one_len_common(const char *name, struct vfsmount *mnt, static int lookup_one_len_common(const char *name, struct dentry *base,
struct dentry *base, int len, struct qstr *this) int len, struct qstr *this)
{ {
this->name = name; this->name = name;
this->len = len; this->len = len;
@ -2583,7 +2573,7 @@ static int lookup_one_len_common(const char *name, struct vfsmount *mnt,
return err; return err;
} }
return inode_permission2(mnt, base->d_inode, MAY_EXEC); return inode_permission(base->d_inode, MAY_EXEC);
} }
/** /**
@ -2607,7 +2597,7 @@ struct dentry *try_lookup_one_len(const char *name, struct dentry *base, int len
WARN_ON_ONCE(!inode_is_locked(base->d_inode)); WARN_ON_ONCE(!inode_is_locked(base->d_inode));
err = lookup_one_len_common(name, NULL, base, len, &this); err = lookup_one_len_common(name, base, len, &this);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
@ -2626,7 +2616,7 @@ EXPORT_SYMBOL(try_lookup_one_len);
* *
* The caller must hold base->i_mutex. * The caller must hold base->i_mutex.
*/ */
struct dentry *lookup_one_len2(const char *name, struct vfsmount *mnt, struct dentry *base, int len) struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
{ {
struct dentry *dentry; struct dentry *dentry;
struct qstr this; struct qstr this;
@ -2634,19 +2624,13 @@ struct dentry *lookup_one_len2(const char *name, struct vfsmount *mnt, struct de
WARN_ON_ONCE(!inode_is_locked(base->d_inode)); WARN_ON_ONCE(!inode_is_locked(base->d_inode));
err = lookup_one_len_common(name, mnt, base, len, &this); err = lookup_one_len_common(name, base, len, &this);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
dentry = lookup_dcache(&this, base, 0); dentry = lookup_dcache(&this, base, 0);
return dentry ? dentry : __lookup_slow(&this, base, 0); return dentry ? dentry : __lookup_slow(&this, base, 0);
} }
EXPORT_SYMBOL_GPL(lookup_one_len2);
struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
{
return lookup_one_len2(name, NULL, base, len);
}
EXPORT_SYMBOL(lookup_one_len); EXPORT_SYMBOL(lookup_one_len);
/** /**
@ -2668,7 +2652,7 @@ struct dentry *lookup_one_len_unlocked(const char *name,
int err; int err;
struct dentry *ret; struct dentry *ret;
err = lookup_one_len_common(name, NULL, base, len, &this); err = lookup_one_len_common(name, base, len, &this);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
@ -2766,7 +2750,7 @@ EXPORT_SYMBOL(__check_sticky);
* 11. We don't allow removal of NFS sillyrenamed files; it's handled by * 11. We don't allow removal of NFS sillyrenamed files; it's handled by
* nfs_async_unlink(). * nfs_async_unlink().
*/ */
static int may_delete(struct vfsmount *mnt, struct inode *dir, struct dentry *victim, bool isdir) static int may_delete(struct inode *dir, struct dentry *victim, bool isdir)
{ {
struct inode *inode = d_backing_inode(victim); struct inode *inode = d_backing_inode(victim);
int error; int error;
@ -2783,7 +2767,7 @@ static int may_delete(struct vfsmount *mnt, struct inode *dir, struct dentry *vi
audit_inode_child(dir, victim, AUDIT_TYPE_CHILD_DELETE); audit_inode_child(dir, victim, AUDIT_TYPE_CHILD_DELETE);
error = inode_permission2(mnt, dir, MAY_WRITE | MAY_EXEC); error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
if (error) if (error)
return error; return error;
if (IS_APPEND(dir)) if (IS_APPEND(dir))
@ -2815,7 +2799,7 @@ static int may_delete(struct vfsmount *mnt, struct inode *dir, struct dentry *vi
* 4. We should have write and exec permissions on dir * 4. We should have write and exec permissions on dir
* 5. We can't do it if dir is immutable (done in permission()) * 5. We can't do it if dir is immutable (done in permission())
*/ */
static inline int may_create(struct vfsmount *mnt, struct inode *dir, struct dentry *child) static inline int may_create(struct inode *dir, struct dentry *child)
{ {
struct user_namespace *s_user_ns; struct user_namespace *s_user_ns;
audit_inode_child(dir, child, AUDIT_TYPE_CHILD_CREATE); audit_inode_child(dir, child, AUDIT_TYPE_CHILD_CREATE);
@ -2827,7 +2811,7 @@ static inline int may_create(struct vfsmount *mnt, struct inode *dir, struct den
if (!kuid_has_mapping(s_user_ns, current_fsuid()) || if (!kuid_has_mapping(s_user_ns, current_fsuid()) ||
!kgid_has_mapping(s_user_ns, current_fsgid())) !kgid_has_mapping(s_user_ns, current_fsgid()))
return -EOVERFLOW; return -EOVERFLOW;
return inode_permission2(mnt, dir, MAY_WRITE | MAY_EXEC); return inode_permission(dir, MAY_WRITE | MAY_EXEC);
} }
/* /*
@ -2874,10 +2858,10 @@ void unlock_rename(struct dentry *p1, struct dentry *p2)
} }
EXPORT_SYMBOL(unlock_rename); EXPORT_SYMBOL(unlock_rename);
int vfs_create2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry, int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
umode_t mode, bool want_excl) bool want_excl)
{ {
int error = may_create(mnt, dir, dentry); int error = may_create(dir, dentry);
if (error) if (error)
return error; return error;
@ -2893,21 +2877,14 @@ int vfs_create2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry,
fsnotify_create(dir, dentry); fsnotify_create(dir, dentry);
return error; return error;
} }
EXPORT_SYMBOL_GPL(vfs_create2);
int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
bool want_excl)
{
return vfs_create2(NULL, dir, dentry, mode, want_excl);
}
EXPORT_SYMBOL(vfs_create); EXPORT_SYMBOL(vfs_create);
int vfs_mkobj2(struct vfsmount *mnt, struct dentry *dentry, umode_t mode, int vfs_mkobj(struct dentry *dentry, umode_t mode,
int (*f)(struct dentry *, umode_t, void *), int (*f)(struct dentry *, umode_t, void *),
void *arg) void *arg)
{ {
struct inode *dir = dentry->d_parent->d_inode; struct inode *dir = dentry->d_parent->d_inode;
int error = may_create(mnt, dir, dentry); int error = may_create(dir, dentry);
if (error) if (error)
return error; return error;
@ -2921,15 +2898,6 @@ int vfs_mkobj2(struct vfsmount *mnt, struct dentry *dentry, umode_t mode,
fsnotify_create(dir, dentry); fsnotify_create(dir, dentry);
return error; return error;
} }
EXPORT_SYMBOL_GPL(vfs_mkobj2);
int vfs_mkobj(struct dentry *dentry, umode_t mode,
int (*f)(struct dentry *, umode_t, void *),
void *arg)
{
return vfs_mkobj2(NULL, dentry, mode, f, arg);
}
EXPORT_SYMBOL(vfs_mkobj); EXPORT_SYMBOL(vfs_mkobj);
bool may_open_dev(const struct path *path) bool may_open_dev(const struct path *path)
@ -2941,7 +2909,6 @@ bool may_open_dev(const struct path *path)
static int may_open(const struct path *path, int acc_mode, int flag) static int may_open(const struct path *path, int acc_mode, int flag)
{ {
struct dentry *dentry = path->dentry; struct dentry *dentry = path->dentry;
struct vfsmount *mnt = path->mnt;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
int error; int error;
@ -2966,7 +2933,7 @@ static int may_open(const struct path *path, int acc_mode, int flag)
break; break;
} }
error = inode_permission2(mnt, inode, MAY_OPEN | acc_mode); error = inode_permission(inode, MAY_OPEN | acc_mode);
if (error) if (error)
return error; return error;
@ -3028,7 +2995,7 @@ static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t m
!kgid_has_mapping(s_user_ns, current_fsgid())) !kgid_has_mapping(s_user_ns, current_fsgid()))
return -EOVERFLOW; return -EOVERFLOW;
error = inode_permission2(dir->mnt, dir->dentry->d_inode, MAY_WRITE | MAY_EXEC); error = inode_permission(dir->dentry->d_inode, MAY_WRITE | MAY_EXEC);
if (error) if (error)
return error; return error;
@ -3365,8 +3332,7 @@ struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode, int open_flag)
int error; int error;
/* we want directory to be writable */ /* we want directory to be writable */
error = inode_permission2(ERR_PTR(-EOPNOTSUPP), dir, error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
MAY_WRITE | MAY_EXEC);
if (error) if (error)
goto out_err; goto out_err;
error = -EOPNOTSUPP; error = -EOPNOTSUPP;
@ -3621,9 +3587,9 @@ inline struct dentry *user_path_create(int dfd, const char __user *pathname,
} }
EXPORT_SYMBOL(user_path_create); EXPORT_SYMBOL(user_path_create);
int vfs_mknod2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
{ {
int error = may_create(mnt, dir, dentry); int error = may_create(dir, dentry);
if (error) if (error)
return error; return error;
@ -3647,12 +3613,6 @@ int vfs_mknod2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry, u
fsnotify_create(dir, dentry); fsnotify_create(dir, dentry);
return error; return error;
} }
EXPORT_SYMBOL_GPL(vfs_mknod2);
int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
{
return vfs_mknod2(NULL, dir, dentry, mode, dev);
}
EXPORT_SYMBOL(vfs_mknod); EXPORT_SYMBOL(vfs_mknod);
static int may_mknod(umode_t mode) static int may_mknod(umode_t mode)
@ -3695,12 +3655,12 @@ long do_mknodat(int dfd, const char __user *filename, umode_t mode,
goto out; goto out;
switch (mode & S_IFMT) { switch (mode & S_IFMT) {
case 0: case S_IFREG: case 0: case S_IFREG:
error = vfs_create2(path.mnt, path.dentry->d_inode,dentry,mode,true); error = vfs_create(path.dentry->d_inode,dentry,mode,true);
if (!error) if (!error)
ima_post_path_mknod(dentry); ima_post_path_mknod(dentry);
break; break;
case S_IFCHR: case S_IFBLK: case S_IFCHR: case S_IFBLK:
error = vfs_mknod2(path.mnt, path.dentry->d_inode,dentry,mode, error = vfs_mknod(path.dentry->d_inode,dentry,mode,
new_decode_dev(dev)); new_decode_dev(dev));
break; break;
case S_IFIFO: case S_IFSOCK: case S_IFIFO: case S_IFSOCK:
@ -3727,9 +3687,9 @@ SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, d
return do_mknodat(AT_FDCWD, filename, mode, dev); return do_mknodat(AT_FDCWD, filename, mode, dev);
} }
int vfs_mkdir2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry, umode_t mode) int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
{ {
int error = may_create(mnt, dir, dentry); int error = may_create(dir, dentry);
unsigned max_links = dir->i_sb->s_max_links; unsigned max_links = dir->i_sb->s_max_links;
if (error) if (error)
@ -3751,12 +3711,6 @@ int vfs_mkdir2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry, u
fsnotify_mkdir(dir, dentry); fsnotify_mkdir(dir, dentry);
return error; return error;
} }
EXPORT_SYMBOL_GPL(vfs_mkdir2);
int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
{
return vfs_mkdir2(NULL, dir, dentry, mode);
}
EXPORT_SYMBOL(vfs_mkdir); EXPORT_SYMBOL(vfs_mkdir);
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode) long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
@ -3775,7 +3729,7 @@ long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
mode &= ~current_umask(); mode &= ~current_umask();
error = security_path_mkdir(&path, dentry, mode); error = security_path_mkdir(&path, dentry, mode);
if (!error) if (!error)
error = vfs_mkdir2(path.mnt, path.dentry->d_inode, dentry, mode); error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
done_path_create(&path, dentry); done_path_create(&path, dentry);
if (retry_estale(error, lookup_flags)) { if (retry_estale(error, lookup_flags)) {
lookup_flags |= LOOKUP_REVAL; lookup_flags |= LOOKUP_REVAL;
@ -3794,9 +3748,9 @@ SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
return do_mkdirat(AT_FDCWD, pathname, mode); return do_mkdirat(AT_FDCWD, pathname, mode);
} }
int vfs_rmdir2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry) int vfs_rmdir(struct inode *dir, struct dentry *dentry)
{ {
int error = may_delete(mnt, dir, dentry, 1); int error = may_delete(dir, dentry, 1);
if (error) if (error)
return error; return error;
@ -3832,12 +3786,6 @@ int vfs_rmdir2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry)
d_delete(dentry); d_delete(dentry);
return error; return error;
} }
EXPORT_SYMBOL_GPL(vfs_rmdir2);
int vfs_rmdir(struct inode *dir, struct dentry *dentry)
{
return vfs_rmdir2(NULL, dir, dentry);
}
EXPORT_SYMBOL(vfs_rmdir); EXPORT_SYMBOL(vfs_rmdir);
long do_rmdir(int dfd, const char __user *pathname) long do_rmdir(int dfd, const char __user *pathname)
@ -3883,7 +3831,7 @@ long do_rmdir(int dfd, const char __user *pathname)
error = security_path_rmdir(&path, dentry); error = security_path_rmdir(&path, dentry);
if (error) if (error)
goto exit3; goto exit3;
error = vfs_rmdir2(path.mnt, path.dentry->d_inode, dentry); error = vfs_rmdir(path.dentry->d_inode, dentry);
exit3: exit3:
dput(dentry); dput(dentry);
exit2: exit2:
@ -3922,10 +3870,10 @@ SYSCALL_DEFINE1(rmdir, const char __user *, pathname)
* be appropriate for callers that expect the underlying filesystem not * be appropriate for callers that expect the underlying filesystem not
* to be NFS exported. * to be NFS exported.
*/ */
int vfs_unlink2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry, struct inode **delegated_inode) int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegated_inode)
{ {
struct inode *target = dentry->d_inode; struct inode *target = dentry->d_inode;
int error = may_delete(mnt, dir, dentry, 0); int error = may_delete(dir, dentry, 0);
if (error) if (error)
return error; return error;
@ -3961,12 +3909,6 @@ int vfs_unlink2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry,
return error; return error;
} }
EXPORT_SYMBOL_GPL(vfs_unlink2);
int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegated_inode)
{
return vfs_unlink2(NULL, dir, dentry, delegated_inode);
}
EXPORT_SYMBOL(vfs_unlink); EXPORT_SYMBOL(vfs_unlink);
/* /*
@ -4012,7 +3954,7 @@ long do_unlinkat(int dfd, struct filename *name)
error = security_path_unlink(&path, dentry); error = security_path_unlink(&path, dentry);
if (error) if (error)
goto exit2; goto exit2;
error = vfs_unlink2(path.mnt, path.dentry->d_inode, dentry, &delegated_inode); error = vfs_unlink(path.dentry->d_inode, dentry, &delegated_inode);
exit2: exit2:
dput(dentry); dput(dentry);
} }
@ -4062,9 +4004,9 @@ SYSCALL_DEFINE1(unlink, const char __user *, pathname)
return do_unlinkat(AT_FDCWD, getname(pathname)); return do_unlinkat(AT_FDCWD, getname(pathname));
} }
int vfs_symlink2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry, const char *oldname) int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
{ {
int error = may_create(mnt, dir, dentry); int error = may_create(dir, dentry);
if (error) if (error)
return error; return error;
@ -4081,12 +4023,6 @@ int vfs_symlink2(struct vfsmount *mnt, struct inode *dir, struct dentry *dentry,
fsnotify_create(dir, dentry); fsnotify_create(dir, dentry);
return error; return error;
} }
EXPORT_SYMBOL_GPL(vfs_symlink2);
int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
{
return vfs_symlink2(NULL, dir, dentry, oldname);
}
EXPORT_SYMBOL(vfs_symlink); EXPORT_SYMBOL(vfs_symlink);
long do_symlinkat(const char __user *oldname, int newdfd, long do_symlinkat(const char __user *oldname, int newdfd,
@ -4109,7 +4045,7 @@ long do_symlinkat(const char __user *oldname, int newdfd,
error = security_path_symlink(&path, dentry, from->name); error = security_path_symlink(&path, dentry, from->name);
if (!error) if (!error)
error = vfs_symlink2(path.mnt, path.dentry->d_inode, dentry, from->name); error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
done_path_create(&path, dentry); done_path_create(&path, dentry);
if (retry_estale(error, lookup_flags)) { if (retry_estale(error, lookup_flags)) {
lookup_flags |= LOOKUP_REVAL; lookup_flags |= LOOKUP_REVAL;
@ -4150,7 +4086,7 @@ SYSCALL_DEFINE2(symlink, const char __user *, oldname, const char __user *, newn
* be appropriate for callers that expect the underlying filesystem not * be appropriate for callers that expect the underlying filesystem not
* to be NFS exported. * to be NFS exported.
*/ */
int vfs_link2(struct vfsmount *mnt, struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry, struct inode **delegated_inode) int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry, struct inode **delegated_inode)
{ {
struct inode *inode = old_dentry->d_inode; struct inode *inode = old_dentry->d_inode;
unsigned max_links = dir->i_sb->s_max_links; unsigned max_links = dir->i_sb->s_max_links;
@ -4159,7 +4095,7 @@ int vfs_link2(struct vfsmount *mnt, struct dentry *old_dentry, struct inode *dir
if (!inode) if (!inode)
return -ENOENT; return -ENOENT;
error = may_create(mnt, dir, new_dentry); error = may_create(dir, new_dentry);
if (error) if (error)
return error; return error;
@ -4209,12 +4145,6 @@ int vfs_link2(struct vfsmount *mnt, struct dentry *old_dentry, struct inode *dir
fsnotify_link(dir, inode, new_dentry); fsnotify_link(dir, inode, new_dentry);
return error; return error;
} }
EXPORT_SYMBOL_GPL(vfs_link2);
int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry, struct inode **delegated_inode)
{
return vfs_link2(NULL, old_dentry, dir, new_dentry, delegated_inode);
}
EXPORT_SYMBOL(vfs_link); EXPORT_SYMBOL(vfs_link);
/* /*
@ -4270,7 +4200,7 @@ int do_linkat(int olddfd, const char __user *oldname, int newdfd,
error = security_path_link(old_path.dentry, &new_path, new_dentry); error = security_path_link(old_path.dentry, &new_path, new_dentry);
if (error) if (error)
goto out_dput; goto out_dput;
error = vfs_link2(old_path.mnt, old_path.dentry, new_path.dentry->d_inode, new_dentry, &delegated_inode); error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry, &delegated_inode);
out_dput: out_dput:
done_path_create(&new_path, new_dentry); done_path_create(&new_path, new_dentry);
if (delegated_inode) { if (delegated_inode) {
@ -4352,8 +4282,7 @@ SYSCALL_DEFINE2(link, const char __user *, oldname, const char __user *, newname
* ->i_mutex on parents, which works but leads to some truly excessive * ->i_mutex on parents, which works but leads to some truly excessive
* locking]. * locking].
*/ */
int vfs_rename2(struct vfsmount *mnt, int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry, struct inode *new_dir, struct dentry *new_dentry,
struct inode **delegated_inode, unsigned int flags) struct inode **delegated_inode, unsigned int flags)
{ {
@ -4368,19 +4297,19 @@ int vfs_rename2(struct vfsmount *mnt,
if (source == target) if (source == target)
return 0; return 0;
error = may_delete(mnt, old_dir, old_dentry, is_dir); error = may_delete(old_dir, old_dentry, is_dir);
if (error) if (error)
return error; return error;
if (!target) { if (!target) {
error = may_create(mnt, new_dir, new_dentry); error = may_create(new_dir, new_dentry);
} else { } else {
new_is_dir = d_is_dir(new_dentry); new_is_dir = d_is_dir(new_dentry);
if (!(flags & RENAME_EXCHANGE)) if (!(flags & RENAME_EXCHANGE))
error = may_delete(mnt, new_dir, new_dentry, is_dir); error = may_delete(new_dir, new_dentry, is_dir);
else else
error = may_delete(mnt, new_dir, new_dentry, new_is_dir); error = may_delete(new_dir, new_dentry, new_is_dir);
} }
if (error) if (error)
return error; return error;
@ -4394,12 +4323,12 @@ int vfs_rename2(struct vfsmount *mnt,
*/ */
if (new_dir != old_dir) { if (new_dir != old_dir) {
if (is_dir) { if (is_dir) {
error = inode_permission2(mnt, source, MAY_WRITE); error = inode_permission(source, MAY_WRITE);
if (error) if (error)
return error; return error;
} }
if ((flags & RENAME_EXCHANGE) && new_is_dir) { if ((flags & RENAME_EXCHANGE) && new_is_dir) {
error = inode_permission2(mnt, target, MAY_WRITE); error = inode_permission(target, MAY_WRITE);
if (error) if (error)
return error; return error;
} }
@ -4476,14 +4405,6 @@ int vfs_rename2(struct vfsmount *mnt,
return error; return error;
} }
EXPORT_SYMBOL_GPL(vfs_rename2);
int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
struct inode **delegated_inode, unsigned int flags)
{
return vfs_rename2(NULL, old_dir, old_dentry, new_dir, new_dentry, delegated_inode, flags);
}
EXPORT_SYMBOL(vfs_rename); EXPORT_SYMBOL(vfs_rename);
static int do_renameat2(int olddfd, const char __user *oldname, int newdfd, static int do_renameat2(int olddfd, const char __user *oldname, int newdfd,
@ -4597,7 +4518,7 @@ static int do_renameat2(int olddfd, const char __user *oldname, int newdfd,
&new_path, new_dentry, flags); &new_path, new_dentry, flags);
if (error) if (error)
goto exit5; goto exit5;
error = vfs_rename2(old_path.mnt, old_path.dentry->d_inode, old_dentry, error = vfs_rename(old_path.dentry->d_inode, old_dentry,
new_path.dentry->d_inode, new_dentry, new_path.dentry->d_inode, new_dentry,
&delegated_inode, flags); &delegated_inode, flags);
exit5: exit5:
@ -4648,7 +4569,7 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
int vfs_whiteout(struct inode *dir, struct dentry *dentry) int vfs_whiteout(struct inode *dir, struct dentry *dentry)
{ {
int error = may_create(NULL, dir, dentry); int error = may_create(dir, dentry);
if (error) if (error)
return error; return error;

View File

@ -634,7 +634,7 @@ static int fanotify_find_path(int dfd, const char __user *filename,
} }
/* you can only watch an inode if you have read permissions on it */ /* you can only watch an inode if you have read permissions on it */
ret = inode_permission2(path->mnt, path->dentry->d_inode, MAY_READ); ret = inode_permission(path->dentry->d_inode, MAY_READ);
if (ret) { if (ret) {
path_put(path); path_put(path);
goto out; goto out;

View File

@ -341,7 +341,7 @@ static int inotify_find_inode(const char __user *dirname, struct path *path,
if (error) if (error)
return error; return error;
/* you can only watch an inode if you have read permissions on it */ /* you can only watch an inode if you have read permissions on it */
error = inode_permission2(path->mnt, path->dentry->d_inode, MAY_READ); error = inode_permission(path->dentry->d_inode, MAY_READ);
if (error) { if (error) {
path_put(path); path_put(path);
return error; return error;

View File

@ -90,7 +90,7 @@ long vfs_truncate(const struct path *path, loff_t length)
if (error) if (error)
goto out; goto out;
error = inode_permission2(mnt, inode, MAY_WRITE); error = inode_permission(inode, MAY_WRITE);
if (error) if (error)
goto mnt_drop_write_and_out; goto mnt_drop_write_and_out;
@ -360,7 +360,6 @@ long do_faccessat(int dfd, const char __user *filename, int mode)
struct cred *override_cred; struct cred *override_cred;
struct path path; struct path path;
struct inode *inode; struct inode *inode;
struct vfsmount *mnt;
int res; int res;
unsigned int lookup_flags = LOOKUP_FOLLOW; unsigned int lookup_flags = LOOKUP_FOLLOW;
@ -410,7 +409,6 @@ long do_faccessat(int dfd, const char __user *filename, int mode)
goto out; goto out;
inode = d_backing_inode(path.dentry); inode = d_backing_inode(path.dentry);
mnt = path.mnt;
if ((mode & MAY_EXEC) && S_ISREG(inode->i_mode)) { if ((mode & MAY_EXEC) && S_ISREG(inode->i_mode)) {
/* /*
@ -422,7 +420,7 @@ long do_faccessat(int dfd, const char __user *filename, int mode)
goto out_path_release; goto out_path_release;
} }
res = inode_permission2(mnt, inode, mode | MAY_ACCESS); res = inode_permission(inode, mode | MAY_ACCESS);
/* SuS v2 requires we report a read only fs too */ /* SuS v2 requires we report a read only fs too */
if (res || !(mode & S_IWOTH) || special_file(inode->i_mode)) if (res || !(mode & S_IWOTH) || special_file(inode->i_mode))
goto out_path_release; goto out_path_release;
@ -471,7 +469,7 @@ int ksys_chdir(const char __user *filename)
if (error) if (error)
goto out; goto out;
error = inode_permission2(path.mnt, path.dentry->d_inode, MAY_EXEC | MAY_CHDIR); error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
if (error) if (error)
goto dput_and_out; goto dput_and_out;
@ -505,8 +503,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
if (!d_can_lookup(f.file->f_path.dentry)) if (!d_can_lookup(f.file->f_path.dentry))
goto out_putf; goto out_putf;
error = inode_permission2(f.file->f_path.mnt, file_inode(f.file), error = inode_permission(file_inode(f.file), MAY_EXEC | MAY_CHDIR);
MAY_EXEC | MAY_CHDIR);
if (!error) if (!error)
set_fs_pwd(current->fs, &f.file->f_path); set_fs_pwd(current->fs, &f.file->f_path);
out_putf: out_putf:
@ -525,7 +522,7 @@ int ksys_chroot(const char __user *filename)
if (error) if (error)
goto out; goto out;
error = inode_permission2(path.mnt, path.dentry->d_inode, MAY_EXEC | MAY_CHDIR); error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
if (error) if (error)
goto dput_and_out; goto dput_and_out;

View File

@ -131,7 +131,7 @@ xattr_permission(struct inode *inode, const char *name, int mask)
return -EPERM; return -EPERM;
} }
return inode_permission2(ERR_PTR(-EOPNOTSUPP), inode, mask); return inode_permission(inode, mask);
} }
int int

View File

@ -1724,21 +1724,13 @@ extern bool inode_owner_or_capable(const struct inode *inode);
* VFS helper functions.. * VFS helper functions..
*/ */
extern int vfs_create(struct inode *, struct dentry *, umode_t, bool); extern int vfs_create(struct inode *, struct dentry *, umode_t, bool);
extern int vfs_create2(struct vfsmount *, struct inode *, struct dentry *, umode_t, bool);
extern int vfs_mkdir(struct inode *, struct dentry *, umode_t); extern int vfs_mkdir(struct inode *, struct dentry *, umode_t);
extern int vfs_mkdir2(struct vfsmount *, struct inode *, struct dentry *, umode_t);
extern int vfs_mknod(struct inode *, struct dentry *, umode_t, dev_t); extern int vfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
extern int vfs_mknod2(struct vfsmount *, struct inode *, struct dentry *, umode_t, dev_t);
extern int vfs_symlink(struct inode *, struct dentry *, const char *); extern int vfs_symlink(struct inode *, struct dentry *, const char *);
extern int vfs_symlink2(struct vfsmount *, struct inode *, struct dentry *, const char *);
extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode **); extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode **);
extern int vfs_link2(struct vfsmount *, struct dentry *, struct inode *, struct dentry *, struct inode **);
extern int vfs_rmdir(struct inode *, struct dentry *); extern int vfs_rmdir(struct inode *, struct dentry *);
extern int vfs_rmdir2(struct vfsmount *, struct inode *, struct dentry *);
extern int vfs_unlink(struct inode *, struct dentry *, struct inode **); extern int vfs_unlink(struct inode *, struct dentry *, struct inode **);
extern int vfs_unlink2(struct vfsmount *, struct inode *, struct dentry *, struct inode **);
extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int); extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int);
extern int vfs_rename2(struct vfsmount *, struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int);
extern int vfs_whiteout(struct inode *, struct dentry *); extern int vfs_whiteout(struct inode *, struct dentry *);
extern struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode, extern struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode,
@ -1747,9 +1739,6 @@ extern struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode,
int vfs_mkobj(struct dentry *, umode_t, int vfs_mkobj(struct dentry *, umode_t,
int (*f)(struct dentry *, umode_t, void *), int (*f)(struct dentry *, umode_t, void *),
void *); void *);
int vfs_mkobj2(struct vfsmount *, struct dentry *, umode_t,
int (*f)(struct dentry *, umode_t, void *),
void *);
extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
@ -1890,7 +1879,6 @@ struct inode_operations {
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
const char * (*get_link) (struct dentry *, struct inode *, struct delayed_call *); const char * (*get_link) (struct dentry *, struct inode *, struct delayed_call *);
int (*permission) (struct inode *, int); int (*permission) (struct inode *, int);
int (*permission2) (struct vfsmount *, struct inode *, int);
struct posix_acl * (*get_acl)(struct inode *, int); struct posix_acl * (*get_acl)(struct inode *, int);
int (*readlink) (struct dentry *, char __user *,int); int (*readlink) (struct dentry *, char __user *,int);
@ -2924,7 +2912,6 @@ static inline int bmap(struct inode *inode, sector_t *block)
extern int notify_change(struct dentry *, struct iattr *, struct inode **); extern int notify_change(struct dentry *, struct iattr *, struct inode **);
extern int notify_change2(struct vfsmount *, struct dentry *, struct iattr *, struct inode **); extern int notify_change2(struct vfsmount *, struct dentry *, struct iattr *, struct inode **);
extern int inode_permission(struct inode *, int); extern int inode_permission(struct inode *, int);
extern int inode_permission2(struct vfsmount *, struct inode *, int);
extern int generic_permission(struct inode *, int); extern int generic_permission(struct inode *, int);
extern int __check_sticky(struct inode *dir, struct inode *inode); extern int __check_sticky(struct inode *dir, struct inode *inode);

View File

@ -68,7 +68,6 @@ extern struct dentry *kern_path_locked(const char *, struct path *);
extern struct dentry *try_lookup_one_len(const char *, struct dentry *, int); extern struct dentry *try_lookup_one_len(const char *, struct dentry *, int);
extern struct dentry *lookup_one_len(const char *, struct dentry *, int); extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
extern struct dentry *lookup_one_len2(const char *, struct vfsmount *mnt, struct dentry *, int);
extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int); extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int);
extern struct dentry *lookup_positive_unlocked(const char *, struct dentry *, int); extern struct dentry *lookup_positive_unlocked(const char *, struct dentry *, int);

View File

@ -849,7 +849,7 @@ static void remove_notification(struct mqueue_inode_info *info)
info->notify_user_ns = NULL; info->notify_user_ns = NULL;
} }
static int prepare_open(struct vfsmount *mnt, struct dentry *dentry, int oflag, int ro, static int prepare_open(struct dentry *dentry, int oflag, int ro,
umode_t mode, struct filename *name, umode_t mode, struct filename *name,
struct mq_attr *attr) struct mq_attr *attr)
{ {
@ -863,7 +863,7 @@ static int prepare_open(struct vfsmount *mnt, struct dentry *dentry, int oflag,
if (ro) if (ro)
return ro; return ro;
audit_inode_parent_hidden(name, dentry->d_parent); audit_inode_parent_hidden(name, dentry->d_parent);
return vfs_mkobj2(mnt, dentry, mode & ~current_umask(), return vfs_mkobj(dentry, mode & ~current_umask(),
mqueue_create_attr, attr); mqueue_create_attr, attr);
} }
/* it already existed */ /* it already existed */
@ -873,7 +873,7 @@ static int prepare_open(struct vfsmount *mnt, struct dentry *dentry, int oflag,
if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY)) if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY))
return -EINVAL; return -EINVAL;
acc = oflag2acc[oflag & O_ACCMODE]; acc = oflag2acc[oflag & O_ACCMODE];
return inode_permission2(mnt, d_inode(dentry), acc); return inode_permission(d_inode(dentry), acc);
} }
static int do_mq_open(const char __user *u_name, int oflag, umode_t mode, static int do_mq_open(const char __user *u_name, int oflag, umode_t mode,
@ -897,13 +897,13 @@ static int do_mq_open(const char __user *u_name, int oflag, umode_t mode,
ro = mnt_want_write(mnt); /* we'll drop it in any case */ ro = mnt_want_write(mnt); /* we'll drop it in any case */
inode_lock(d_inode(root)); inode_lock(d_inode(root));
path.dentry = lookup_one_len2(name->name, mnt, root, strlen(name->name)); path.dentry = lookup_one_len(name->name, root, strlen(name->name));
if (IS_ERR(path.dentry)) { if (IS_ERR(path.dentry)) {
error = PTR_ERR(path.dentry); error = PTR_ERR(path.dentry);
goto out_putfd; goto out_putfd;
} }
path.mnt = mntget(mnt); path.mnt = mntget(mnt);
error = prepare_open(path.mnt, path.dentry, oflag, ro, mode, name, attr); error = prepare_open(path.dentry, oflag, ro, mode, name, attr);
if (!error) { if (!error) {
struct file *file = dentry_open(&path, oflag, current_cred()); struct file *file = dentry_open(&path, oflag, current_cred());
if (!IS_ERR(file)) if (!IS_ERR(file))
@ -953,7 +953,7 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name)
if (err) if (err)
goto out_name; goto out_name;
inode_lock_nested(d_inode(mnt->mnt_root), I_MUTEX_PARENT); inode_lock_nested(d_inode(mnt->mnt_root), I_MUTEX_PARENT);
dentry = lookup_one_len2(name->name, mnt, mnt->mnt_root, dentry = lookup_one_len(name->name, mnt->mnt_root,
strlen(name->name)); strlen(name->name));
if (IS_ERR(dentry)) { if (IS_ERR(dentry)) {
err = PTR_ERR(dentry); err = PTR_ERR(dentry);
@ -965,7 +965,7 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name)
err = -ENOENT; err = -ENOENT;
} else { } else {
ihold(inode); ihold(inode);
err = vfs_unlink2(mnt, d_inode(dentry->d_parent), dentry, NULL); err = vfs_unlink(d_inode(dentry->d_parent), dentry, NULL);
} }
dput(dentry); dput(dentry);

View File

@ -128,7 +128,7 @@ static struct dentry *securityfs_create_dentry(const char *name, umode_t mode,
dir = d_inode(parent); dir = d_inode(parent);
inode_lock(dir); inode_lock(dir);
dentry = lookup_one_len2(name, mount, parent, strlen(name)); dentry = lookup_one_len(name, parent, strlen(name));
if (IS_ERR(dentry)) if (IS_ERR(dentry))
goto out; goto out;