* [BUG][PATCH] hugetlbfs vm_pgoff bugs.
@ 2004-07-09 14:12 Oleg Nesterov
0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2004-07-09 14:12 UTC (permalink / raw)
To: linux-kernel; +Cc: Andrew Morton, William Lee Irwin III, David Gibson
Hello.
1. hugetlbfs_file_mmap() must check that vm_pgoff is hugepage aligned.
2. hugetlb_vmtruncate_list() confuses << with >> while converting
vm_pgoff to huge page offset, and zaps wrong area.
Patch against mm7.
Oleg.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- 2.6.7-mm7/fs/hugetlbfs/inode.c.orig 2004-07-09 16:41:15.000000000 +0400
+++ 2.6.7-mm7/fs/hugetlbfs/inode.c 2004-07-09 16:56:02.000000000 +0400
@@ -52,6 +52,9 @@ static int hugetlbfs_file_mmap(struct fi
loff_t len, vma_len;
int ret;
+ if (vma->vm_pgoff & (HPAGE_SIZE / PAGE_SIZE - 1))
+ return -EINVAL;
+
if (vma->vm_start & ~HPAGE_MASK)
return -EINVAL;
@@ -280,16 +283,16 @@ hugetlb_vmtruncate_list(struct prio_tree
unsigned long v_length;
unsigned long v_offset;
- h_vm_pgoff = vma->vm_pgoff << (HPAGE_SHIFT - PAGE_SHIFT);
- v_length = vma->vm_end - vma->vm_start;
+ h_vm_pgoff = vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT);
v_offset = (h_pgoff - h_vm_pgoff) << HPAGE_SHIFT;
-
/*
* Is this VMA fully outside the truncation point?
*/
if (h_vm_pgoff >= h_pgoff)
v_offset = 0;
+ v_length = vma->vm_end - vma->vm_start;
+
zap_hugepage_range(vma,
vma->vm_start + v_offset,
v_length - v_offset);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-07-09 14:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-09 14:12 [BUG][PATCH] hugetlbfs vm_pgoff bugs Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome