mirror of
https://github.com/versity/scoutfs.git
synced 2026-02-07 11:10:44 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
Reference in New Issue
Block a user