[PATCH] xfs: Add readpage() check up for mmap file at xfs_file_mmap()
Jeff Liu
jeff.liu at oracle.com
Wed Jul 18 09:47:28 CDT 2012
Hello,
When studying XFS code, I found xfs_file_mmap() does not check whether a specific file has readpage() or not.
Actually, I have no idea of which kind of file does not supply page reading function, but Btrfs/Ext4
as well as generic_file_mmap() all do this check at first, do we also need a defense here?
Thanks,
-Jeff
Signed-off-by: Jie Liu <jeff.liu at oracle.com>
---
fs/xfs/xfs_file.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 9f7ec15..92ad4a5 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -945,6 +945,11 @@ xfs_file_mmap(
struct file *filp,
struct vm_area_struct *vma)
{
+ struct address_space *mapping = file->f_mapping;
+
+ if (!mapping->a_ops->readpage)
+ return -ENOEXEC;
+
vma->vm_ops = &xfs_file_vm_ops;
vma->vm_flags |= VM_CAN_NONLINEAR;
--
1.7.9
More information about the xfs
mailing list