]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/blobdiff - kernel/exit.c
do_exit(): make sure that we run with get_fs() == USER_DS
[lisovros/linux_canprio.git] / kernel / exit.c
index 03120229db2802929065a210930e41c7fa701ba0..d72167d500cb34b396f3abf2bb87f17831584db9 100644 (file)
@@ -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);