Skip to contentSkip to conversation

mm: fix null pointer dereference in vm_normal_page()

PATCH NAK Américo Wang 2 participants 2 messages Feb 18, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: fix null pointer dereference in vm_normal_page()

One usage of vm_normal_page() is:

    struct page *page = vm_normal_page(gate_vma, start, *pte);

where gate_vma is returned by get_gate_vma() which can be NULL. So let vm_normal_page return NULL when vma is NULL.

---

mm/memory.c +3 -0
index baa999e..e428aa6 100644
@@ -493,6 +493,9 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
 {
 	unsigned long pfn = pte_pfn(pte);
 
+	if (!vma)
+		return NULL;
+
 	if (HAVE_PTE_SPECIAL) {
 		if (likely(!pte_special(pte)))
 			goto check_pfn;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Nacked-by on v1 1/1 NAK
#1 lore raw
Quoted 7 lines · Americo Wang

One usage of vm_normal_page() is:

    struct page *page = vm_normal_page(gate_vma, start, *pte);

where gate_vma is returned by get_gate_vma() which can be NULL. So let vm_normal_page return NULL when vma is NULL.

I assume you refer to __get_user_pages()...?

This function checks whether the address is in the gate area and only iff so requests the VMA representing it.

If you really did see an oops that is worked-around by your patch, then the in_gate_area()/get_gate_vma() in question are broken.

Quoted 2 lines
Quoted 8 lines

---

mm/memory.c +0 -0
index baa999e..e428aa6 100644

mm/memory.c struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, · line 501

Quoted 9 lines
mm/memory.c +3 -0
@@ -493,6 +493,9 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
 {
 	unsigned long pfn = pte_pfn(pte);
 
+	if (!vma)
+		return NULL;
+
 	if (HAVE_PTE_SPECIAL) {
 		if (likely(!pte_special(pte)))
 			goto check_pfn;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>