* [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* Re: [PATCH] xfs: Add readpage() check up for mmap file at xfs_file_mmap()
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
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2012-07-18 15:11 UTC (permalink / raw)
To: Jeff Liu; +Cc: xfs
On Wed, Jul 18, 2012 at 10:47:28PM +0800, Jeff Liu wrote:
> 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?
It's not needed. In generic_file_mmap it might make a little sense as
any filesystem could use it, but even there's it's questionable because
->readpage is the only way to actually supposed mmap when using
generic_file_mmap.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: Add readpage() check up for mmap file at xfs_file_mmap()
2012-07-18 15:11 ` Christoph Hellwig
@ 2012-07-19 2:59 ` Jeff Liu
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Liu @ 2012-07-19 2:59 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On 07/18/2012 11:11 PM, Christoph Hellwig wrote:
> On Wed, Jul 18, 2012 at 10:47:28PM +0800, Jeff Liu wrote:
>> 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?
>
> It's not needed. In generic_file_mmap it might make a little sense as
> any filesystem could use it, but even there's it's questionable because
> ->readpage is the only way to actually supposed mmap when using
> generic_file_mmap.
Now I got it, thanks for the teaching.
Thanks,
-Jeff
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [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