public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: Add readpage() check up for mmap file at xfs_file_mmap()
@ 2012-07-18 14:47 Jeff Liu
  2012-07-18 15:11 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Liu @ 2012-07-18 14:47 UTC (permalink / raw)
  To: xfs

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@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

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-19  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-18 14:47 [PATCH] xfs: Add readpage() check up for mmap file at xfs_file_mmap() Jeff Liu
2012-07-18 15:11 ` Christoph Hellwig
2012-07-19  2:59   ` Jeff Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox