do_wait: Add missing tasklist unlocking in error paths.
It looks like both 64a16caf5, and 98abed020 both introduced error paths to do_wait where we miss unlocking the tasklist.
Spotted with coverity.
kernel/exit.c +6 -4
@@ -1526,13 +1526,15 @@ repeat: tsk = current; do { retval = do_wait_thread(wo, tsk); - if (retval) + if (retval) { + read_unlock(&tasklist_lock); goto end; - + } retval = ptrace_do_wait(wo, tsk); - if (retval) + if (retval) { + read_unlock(&tasklist_lock); goto end; - + } if (wo->wo_flags & __WNOTHREAD) break; } while_each_thread(current, tsk);
Quoted 5 lines · Dave Jones
It looks like both
64a16caf5, and98abed020both introduced error paths todo_waitwhere we miss unlocking the tasklist.Spotted with coverity.
Not really, afaics.
kernel/exit.c repeat: · line 1530
Quoted 9 lines
kernel/exit.c +2
-1@@ -1526,13 +1526,15 @@ repeat: tsk = current; do { retval = do_wait_thread(wo, tsk); - if (retval) + if (retval) { + read_unlock(&tasklist_lock);
note that do_wait_thread() paths should drop tasklist if it returns non-zero.
Oleg.
Quoted 9 lines · Oleg Nesterov
Quoted 5 lines · Dave Jones
It looks like both
64a16caf5, and98abed020both introduced error paths todo_waitwhere we miss unlocking the tasklist.Spotted with coverity.
Not really, afaics.
Quoted 11 lines
kernel/exit.c repeat: · line 1530
Quoted 9 lines
kernel/exit.c +2
-1@@ -1526,13 +1526,15 @@ repeat: tsk = current; do { retval = do_wait_thread(wo, tsk); - if (retval) + if (retval) { + read_unlock(&tasklist_lock);note that
do_wait_thread()paths should drop tasklist if it returns non-zero.
Ah, I missed the unlock in wait_task_continued.
I'm not sure why the checker didn't infer that. Perhaps it thinks it's possible we can get take one of the early returns in that function before we do the tasklist unlock.
thanks,
Dave