scoutfs: provide ->permission

We need to lock and refresh the VFS inode before it checks permissions in
system calls, otherwise we risk checking against stale inode metadata.

Signed-off-by: Mark Fasheh <mfasheh@versity.com>
[zab: adapted to newer lock call]
Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Mark Fasheh
2017-07-25 18:58:20 -05:00
committed by Zach Brown
parent c0d3f99a6e
commit 1bcad2e9cc
3 changed files with 24 additions and 0 deletions

View File

@@ -19,6 +19,7 @@
#include <linux/namei.h>
#include "format.h"
#include "file.h"
#include "dir.h"
#include "inode.h"
#include "ioctl.h"
@@ -1131,6 +1132,7 @@ const struct inode_operations scoutfs_dir_iops = {
.listxattr = scoutfs_listxattr,
.removexattr = scoutfs_removexattr,
.symlink = scoutfs_symlink,
.permission = scoutfs_permission,
};
void scoutfs_dir_exit(void)

View File

@@ -83,3 +83,24 @@ out:
return ret;
}
int scoutfs_permission(struct inode *inode, int mask)
{
struct super_block *sb = inode->i_sb;
struct scoutfs_lock *inode_lock = NULL;
int ret;
if (mask & MAY_NOT_BLOCK)
return -ECHILD;
ret = scoutfs_lock_inode(sb, DLM_LOCK_PR, SCOUTFS_LKF_REFRESH_INODE,
inode, &inode_lock);
if (ret)
return ret;
ret = generic_permission(inode, mask);
scoutfs_unlock(sb, inode_lock, DLM_LOCK_PR);
return ret;
}

View File

@@ -5,5 +5,6 @@ ssize_t scoutfs_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos);
ssize_t scoutfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos);
int scoutfs_permission(struct inode *inode, int mask);
#endif /* _SCOUTFS_FILE_H_ */