Patchwork [227/289] do_exit(): make sure that we run with get_fs() == USER_DS

login
register
mail settings
Submitter Greg Kroah-Hartman
Date Dec. 8, 2010, 1 a.m.
Message ID <20101208005744.137844789@clark.site>
Download mbox | patch
Permalink /patch/386992/
State New, archived
Headers show

Comments

Patch

--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -903,6 +903,15 @@  NORET_TYPE void do_exit(long code)
 	if (unlikely(!tsk->pid))
 		panic("Attempted to kill the idle task!");
 
+	/*
+	 * If do_exit is called because this processes oopsed, it's possible
+	 * that get_fs() was left as KERNEL_DS, so reset it to USER_DS before
+	 * continuing. Amongst other possible reasons, this is to prevent
+	 * mm_release()->clear_child_tid() from writing to a user-controlled
+	 * kernel address.
+	 */
+	set_fs(USER_DS);
+
 	tracehook_report_exit(&code);
 
 	validate_creds_for_do_exit(tsk);