Skip to contentSkip to conversation

fix __exit_mm() dereference before check.

PATCH Dave Jones 2 participants 3 messages Apr 16, 2004

lore
Share & tools
lore

Dave Jones

author
#0 lore raw
Quoted 1 line

From a quick look, it appears passing NULL mm's down to mm_release()

isn't a good idea.

Dave

kernel/exit.c renamed from kernel/exit.c~ +2 -1
@@ -482,9 +482,10 @@
 {
 	struct mm_struct *mm = tsk->mm;
 
-	mm_release(tsk, mm);
 	if (!mm)
 		return;
+	mm_release(tsk, mm);
+
 	/*
 	 * Serialize with any possible pending coredump.
 	 * We must hold mmap_sem around checking core_waiters
#1 lore raw
Quoted 3 lines · Dave Jones

From a quick look, it appears passing NULL mm's down to mm_release() isn't a good idea.

Hmm.. Where's the dereference? I don't disagree with the patch per se, but I don't see any real problem.

The mm->mm_users check is protected by "tsk->clear_child_tid", and that will have been cleared already if we ever happen to call __exit_mm() twice, so that one is safe.

So this patch might be a cleanup, but not a "fix" per se.

Linus

Quoted 15 lines
kernel/exit.c renamed from kernel/exit.c~ +2 -1
@@ -482,9 +482,10 @@
 {
 	struct mm_struct *mm = tsk->mm;
 
-	mm_release(tsk, mm);
 	if (!mm)
 		return;
+	mm_release(tsk, mm);
+
 	/*
 	 * Serialize with any possible pending coredump.
 	 * We must hold mmap_sem around checking core_waiters
author
#2 lore raw
Quoted 3 lines · Linus Torvalds

The mm->mm_users check is protected by "tsk->clear_child_tid", and that will have been cleared already if we ever happen to call __exit_mm() twice, so that one is safe.

Yes, I missed this.

Quoted 1 line

So this patch might be a cleanup, but not a "fix" per se.

ACK.

Dave