summaryrefslogtreecommitdiffstats
path: root/fs/ksmbd/vfs.c
diff options
context:
space:
mode:
authorHyunchul Lee <hyc.lee@gmail.com>2021-06-23 06:48:24 +0200
committerNamjae Jeon <namjae.jeon@samsung.com>2021-06-28 09:28:41 +0200
commit6c5e36d13e2a338ed611d2bcc6c615dd0550b17d (patch)
tree3b9d45d6412b8fe8ad727b118122804b73a1cb80 /fs/ksmbd/vfs.c
parentksmbd: factor out a ksmbd_vfs_lock_parent helper (diff)
downloadlinux-6c5e36d13e2a338ed611d2bcc6c615dd0550b17d.tar.xz
linux-6c5e36d13e2a338ed611d2bcc6c615dd0550b17d.zip
ksmbd: set MAY_* flags together with open flags
set MAY_* flags together with open flags and remove ksmbd_vfs_inode_permission(). Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/ksmbd/vfs.c')
-rw-r--r--fs/ksmbd/vfs.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/fs/ksmbd/vfs.c b/fs/ksmbd/vfs.c
index e64eab7a58a8..6181a58e8a33 100644
--- a/fs/ksmbd/vfs.c
+++ b/fs/ksmbd/vfs.c
@@ -95,39 +95,23 @@ out_err:
return ret;
}
-int ksmbd_vfs_inode_permission(struct dentry *dentry, int acc_mode, bool delete)
+int ksmbd_vfs_may_delete(struct dentry *dentry)
{
- int mask, ret = 0;
-
- mask = 0;
- acc_mode &= O_ACCMODE;
-
- if (acc_mode == O_RDONLY)
- mask = MAY_READ;
- else if (acc_mode == O_WRONLY)
- mask = MAY_WRITE;
- else if (acc_mode == O_RDWR)
- mask = MAY_READ | MAY_WRITE;
-
- if (inode_permission(&init_user_ns, d_inode(dentry), mask | MAY_OPEN))
- return -EACCES;
-
- if (delete) {
- struct dentry *parent;
-
- parent = dget_parent(dentry);
- ret = ksmbd_vfs_lock_parent(parent, dentry);
- if (ret) {
- dput(parent);
- return ret;
- }
-
- if (inode_permission(&init_user_ns, d_inode(parent), MAY_EXEC | MAY_WRITE))
- ret = -EACCES;
+ struct dentry *parent;
+ int ret;
- inode_unlock(d_inode(parent));
+ parent = dget_parent(dentry);
+ ret = ksmbd_vfs_lock_parent(parent, dentry);
+ if (ret) {
dput(parent);
+ return ret;
}
+
+ ret = inode_permission(&init_user_ns, d_inode(parent),
+ MAY_EXEC | MAY_WRITE);
+
+ inode_unlock(d_inode(parent));
+ dput(parent);
return ret;
}