Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hugetlb: handle write-protection faults in follow_hugetlb_page

The follow_hugetlb_page() fix I posted (merged as git commit
5b23dbe8173c212d6a326e35347b038705603d39) missed one case. If the pte is
present, but not writable and write access is requested by the caller to
get_user_pages(), the code will do the wrong thing. Rather than calling
hugetlb_fault to make the pte writable, it notes the presence of the pte
and continues.

This simple one-liner makes sure we also fault on the pte for this case.
Please apply.

Signed-off-by: Adam Litke <agl@us.ibm.com>
Acked-by: Dave Kleikamp <shaggy@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Adam Litke and committed by
Linus Torvalds
72fad713 8805f238

+1 -1
+1 -1
mm/hugetlb.c
··· 907 907 */ 908 908 pte = huge_pte_offset(mm, vaddr & HPAGE_MASK); 909 909 910 - if (!pte || pte_none(*pte)) { 910 + if (!pte || pte_none(*pte) || (write && !pte_write(*pte))) { 911 911 int ret; 912 912 913 913 spin_unlock(&mm->page_table_lock);