mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] setup_arg_pages can insert overlapping vma
@ 2004-11-16 23:19 Chris Wright
  2004-11-16 23:23 ` [PATCH 2/2] a.out: error check on set_brk Chris Wright
  2004-11-18 17:39 ` [PATCH 1/2] setup_arg_pages can insert overlapping vma Hugh Dickins
  0 siblings, 2 replies; 6+ messages in thread
From: Chris Wright @ 2004-11-16 23:19 UTC (permalink / raw)
  To: akpm, torvalds; +Cc: linux-kernel

Florian Heinz built an a.out binary that could map bss from 0x0 to
0xc0000000, and setup_arg_pages() would BUG() in insert_vma_struct
because the arg pages overlapped.  This just checks before inserting,
and bails out if it would overlap.

Signed-off-by: Chris Wright <chrisw@osdl.org>

===== fs/exec.c 1.143 vs edited =====
--- 1.143/fs/exec.c	2004-10-28 00:40:03 -07:00
+++ edited/fs/exec.c	2004-11-11 19:24:54 -08:00
@@ -413,6 +413,7 @@
 
 	down_write(&mm->mmap_sem);
 	{
+		struct vm_area_struct *vma;
 		mpnt->vm_mm = mm;
 #ifdef CONFIG_STACK_GROWSUP
 		mpnt->vm_start = stack_base;
@@ -433,6 +434,12 @@
 			mpnt->vm_flags = VM_STACK_FLAGS;
 		mpnt->vm_flags |= mm->def_flags;
 		mpnt->vm_page_prot = protection_map[mpnt->vm_flags & 0x7];
+		vma = find_vma(mm, mpnt->vm_start);
+		if (vma) {
+			up_write(&mm->mmap_sem);
+			kmem_cache_free(vm_area_cachep, mpnt);
+			return -ENOMEM;
+		}
 		insert_vm_struct(mm, mpnt);
 		mm->stack_vm = mm->total_vm = vma_pages(mpnt);
 	}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-11-18 20:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-16 23:19 [PATCH 1/2] setup_arg_pages can insert overlapping vma Chris Wright
2004-11-16 23:23 ` [PATCH 2/2] a.out: error check on set_brk Chris Wright
2004-11-18 17:39 ` [PATCH 1/2] setup_arg_pages can insert overlapping vma Hugh Dickins
2004-11-18 18:55   ` Chris Wright
2004-11-18 19:41     ` Hugh Dickins
2004-11-18 20:07       ` Chris Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®