From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: 'Hugh Dickins' <hugh@veritas.com>,
'Andrew Morton' <akpm@osdl.org>,
bill.irwin@oracle.com
Cc: linux-mm@kvack.org
Subject: [patch] enforce proper tlb flush in unmap_hugepage_range
Date: Tue, 3 Oct 2006 02:28:37 -0700 [thread overview]
Message-ID: <000001c6e6ce$4eb93590$bb80030a@amr.corp.intel.com> (raw)
Spotted by Hugh that hugetlb page is free'ed back to global pool
before performing any TLB flush in unmap_hugepage_range(). This
potentially allow threads to abuse free-alloc race condition.
Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>
---
The generic tlb gather code is unsuitable to use by hugetlb, I
just open coded a page gathering list and delayed put_page until
tlb flush is performed. Huge, please sign-off if you are OK
with this patch.
--- ./mm/hugetlb.c.orig 2006-09-19 20:42:06.000000000 -0700
+++ ./mm/hugetlb.c 2006-10-03 00:04:11.000000000 -0700
@@ -363,12 +363,14 @@ void unmap_hugepage_range(struct vm_area
unsigned long address;
pte_t *ptep;
pte_t pte;
- struct page *page;
+ struct page *page, *tmp;
+ struct list_head page_list;
WARN_ON(!is_vm_hugetlb_page(vma));
BUG_ON(start & ~HPAGE_MASK);
BUG_ON(end & ~HPAGE_MASK);
+ INIT_LIST_HEAD(&page_list);
spin_lock(&mm->page_table_lock);
/* Update high watermark before we lower rss */
@@ -384,12 +386,16 @@ void unmap_hugepage_range(struct vm_area
continue;
page = pte_page(pte);
- put_page(page);
+ list_add(&page->lru, &page_list);
add_mm_counter(mm, file_rss, (int) -(HPAGE_SIZE / PAGE_SIZE));
}
spin_unlock(&mm->page_table_lock);
flush_tlb_range(vma, start, end);
+ list_for_each_entry_safe(page, tmp, &page_list, lru) {
+ list_del(&page->lru);
+ put_page(page);
+ }
}
static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2006-10-03 9:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-03 9:28 Chen, Kenneth W [this message]
2006-10-03 11:52 ` Bill Irwin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000001c6e6ce$4eb93590$bb80030a@amr.corp.intel.com' \
--to=kenneth.w.chen@intel.com \
--cc=akpm@osdl.org \
--cc=bill.irwin@oracle.com \
--cc=hugh@veritas.com \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox