[PATCH] mm: make unmap_vmas() handle non-page-aligned boundary addresses

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johannes Weiner
Date: Saturday, August 16, 2008 - 6:06 pm

zap_pte_range() overruns the page tables if the distance between the
start and end is not a multiple of the pagesize.  Because then,
`start' will never be equal to `end' and we will keep looping.

To fix this, round the boundary addresses to exclude partial pages from
the range completely, we must not unmap them anyway.

Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
---

Hugh Dickins <hugh@veritas.com> writes:


I think this patch fixes it.  exit_mmap() even calls unmap_vmas() with
an ending address of -1UL which is not page-aligned in my book and on my
architecture :)

It is a similar problem to what we had with gup some weeks ago.

diff --git a/mm/memory.c b/mm/memory.c
index 1002f47..483c5d0 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -896,11 +896,17 @@ unsigned long unmap_vmas(struct mmu_gather **tlbp,
 	long zap_work = ZAP_BLOCK_SIZE;
 	unsigned long tlb_start = 0;	/* For tlb_finish_mmu */
 	int tlb_start_valid = 0;
-	unsigned long start = start_addr;
+	unsigned long start;
 	spinlock_t *i_mmap_lock = details? details->i_mmap_lock: NULL;
 	int fullmm = (*tlbp)->fullmm;
 	struct mm_struct *mm = vma->vm_mm;
 
+	/* Preserve partial pages */
+	start_addr = PAGE_ALIGN(start_addr);
+	end_addr &= PAGE_MASK;
+
+	start = start_addr;
+
 	mmu_notifier_invalidate_range_start(mm, start_addr, end_addr);
 	for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) {
 		unsigned long end;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.27-rc3-git3: Reported regressions from 2.6.26, Rafael J. Wysocki, (Sat Aug 16, 12:00 pm)
[Bug #11141] no battery or DC status - Dell i1501, Rafael J. Wysocki, (Sat Aug 16, 12:00 pm)
[Bug #11209] 2.6.27-rc1 process time accounting, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11205] x86: 2.6.27-rc1 does not build with gcc-3.2.3 ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11189] sky2 WOL broken, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11191] 2.6.26-git8: spinlock lockup in c1e_idle(), Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11207] VolanoMark regression with 2.6.27-rc1, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11215] INFO: possible recursive locking detected ps2 ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11220] Heavy suspend and io problems in 2.6.27-rc1-0 ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11219] KVM modules break emergency reboot, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11224] Only three cores found on quad-core machine., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11210] libata badness, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11245] acpi error on 2.6.27-rc1+ (ACPI Error (dsobje ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11237] corrupt PMD after resume, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11230] Kconfig no longer outputs a .config with fres ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11228] p54usb broken by commit b19fa1f, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11263] Re: 2.6.27-rc2: uvcvideo WARNING after suspen ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11260] Regression: USB memory stick triggers several ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11254] KVM: fix userspace ABI breakage, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11272] BUG: parport_serial in 2.6.27-rc1 for NetMos ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11276] build error: CONFIG_OPTIMIZE_INLINING=y cause ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11264] Invalid op opcode in kernel/workqueue, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11271] BUG: fealnx in 2.6.27-rc1, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11279] 2.6.27-rc0 Power Bugs with HP/Compaq Laptops, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11278] 2.6.27-rc2: Very odd top: '5124095h kthreadd' ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11282] Please fix x86 defconfig regression, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11308] tbench regression on each kernel release from ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11296] 2.6.27-rc2-git4: suspend and power off fails ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11293] 2.6.27-rc2: suspend regression on EeePC, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11323] /proc/diskstats does not contain all disk devices, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11316] severe performance regression for iptables na ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11337] Warning in during hotplug on 2.6.27-rc2-git5, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11336] 2.6.27-rc2:stall while mounting root fs, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11333] Rewrite SSB DMA API breaks compilation on ARM, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11335] 2.6.27-rc2-git5 BUG: unable to handle kernel ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11334] myri10ge: use ioremap_wc: compilation failure ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11330] int3: 0000 in tsc_read_refs when using powern ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11341] 2.6.27-rc1 - ext4 e2fsck false prompting for ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11340] LTP overnight run resulted in unusable box, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11339] Only one of my cpus seems to powered down by ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11338] ia64 allmodconfig on current mainline, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11355] Regression in 2.6.27-rc2 when cross-building ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11354] AMD Elan regression with 2.6.27-rc3, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11346] kernel BUG at arch/x86/mm/pat.c:233!, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11344] lockdep link failed, Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11343] SATA Cold Boot Problems with 2.6.27-rc[23] on ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
[Bug #11356] Linux 2.6.27-rc3 - build failure: undefined r ..., Rafael J. Wysocki, (Sat Aug 16, 12:02 pm)
Re: [Bug #11346] kernel BUG at arch/x86/mm/pat.c:233!, Jean Delvare, (Sat Aug 16, 1:45 pm)
Re: [Bug #11237] corrupt PMD after resume, Hugh Dickins, (Sat Aug 16, 4:36 pm)
[PATCH] mm: make unmap_vmas() handle non-page-aligned boun ..., Johannes Weiner, (Sat Aug 16, 6:06 pm)
Re: [Bug #11334] myri10ge: use ioremap_wc: compilation fai ..., Martin Michlmayr, (Sat Aug 16, 11:27 pm)
Re: [Bug #11209] 2.6.27-rc1 process time accounting, Peter Zijlstra, (Sun Aug 17, 1:07 am)
Re: [Bug #11205] x86: 2.6.27-rc1 does not build with gcc-3 ..., Mikael Pettersson, (Sun Aug 17, 2:12 am)
Re: [Bug #11205] x86: 2.6.27-rc1 does not build with gcc-3 ..., Rafael J. Wysocki, (Sun Aug 17, 3:27 am)
Re: [Bug #11260] Regression: USB memory stick triggers sev ..., Rafael J. Wysocki, (Sun Aug 17, 5:18 am)
Re: [Bug #11237] corrupt PMD after resume, Rafael J. Wysocki, (Sun Aug 17, 5:18 am)
Re: [Bug #11209] 2.6.27-rc1 process time accounting, Rafael J. Wysocki, (Sun Aug 17, 5:19 am)
Re: [Bug #11278] 2.6.27-rc2: Very odd top: '5124095h kthre ..., Rafael J. Wysocki, (Sun Aug 17, 5:22 am)
Re: [Bug #11334] myri10ge: use ioremap_wc: compilation fai ..., Rafael J. Wysocki, (Sun Aug 17, 5:35 am)
Re: [Bug #11346] kernel BUG at arch/x86/mm/pat.c:233!, Rafael J. Wysocki, (Sun Aug 17, 5:35 am)
Re: [Bug #11355] Regression in 2.6.27-rc2 when cross-build ..., Rafael J. Wysocki, (Sun Aug 17, 5:39 am)
Re: [Bug #11333] Rewrite SSB DMA API breaks compilation on ARM, Rafael J. Wysocki, (Sun Aug 17, 5:43 am)
Re: [Bug #11346] kernel BUG at arch/x86/mm/pat.c:233!, Ingo Molnar, (Sun Aug 17, 5:46 am)
Re: 2.6.27-rc3-git3: Reported regressions from 2.6.26, Theodore Tso, (Sun Aug 17, 6:51 am)
Re: 2.6.27-rc3-git3: Reported regressions from 2.6.26, Rafael J. Wysocki, (Sun Aug 17, 9:33 am)
Re: [Bug #11254] KVM: fix userspace ABI breakage, Adrian Bunk, (Sun Aug 17, 11:45 am)
Re: [Bug #11228] p54usb broken by commit b19fa1f, Larry Finger, (Sun Aug 17, 2:25 pm)
Re: [Bug #11191] 2.6.26-git8: spinlock lockup in c1e_idle(), Mikhail Kshevetskiy, (Mon Aug 18, 2:45 pm)
Re: [Bug #11191] 2.6.26-git8: spinlock lockup in c1e_idle(), Rafael J. Wysocki, (Mon Aug 18, 2:54 pm)
Re: [Bug #11330] int3: 0000 in tsc_read_refs when using po ..., Rafael J. Wysocki, (Tue Aug 19, 10:02 am)
Re: [Bug #11313] Plugging HDMI causes &quot;unable to handle ke ..., Jeremy Fitzhardinge, (Thu Aug 21, 11:13 am)
Re: [Bug #11313] Plugging HDMI causes &quot;unable to handle ke ..., Jeremy Fitzhardinge, (Thu Aug 21, 11:59 am)