* do_wait: Add missing tasklist unlocking in error paths.
@ 2013-09-20 16:37 Dave Jones
2013-09-20 16:41 ` Oleg Nesterov
0 siblings, 1 reply; 3+ messages in thread
From: Dave Jones @ 2013-09-20 16:37 UTC (permalink / raw)
To: Linux Kernel; +Cc: oleg, roland, Linus Torvalds
It looks like both 64a16caf5, and 98abed020 both introduced error paths to do_wait
where we miss unlocking the tasklist.
Spotted with coverity.
Signed-off-by: Dave Jones <davej@fedoraproject.org>
diff --git a/kernel/exit.c b/kernel/exit.c
index a949819..27004a6 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -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);
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: do_wait: Add missing tasklist unlocking in error paths.
2013-09-20 16:37 do_wait: Add missing tasklist unlocking in error paths Dave Jones
@ 2013-09-20 16:41 ` Oleg Nesterov
2013-09-20 17:03 ` Dave Jones
0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2013-09-20 16:41 UTC (permalink / raw)
To: Dave Jones, Linux Kernel, roland, Linus Torvalds
On 09/20, Dave Jones wrote:
>
> It looks like both 64a16caf5, and 98abed020 both introduced error paths to do_wait
> where we miss unlocking the tasklist.
>
> Spotted with coverity.
Not really, afaics.
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -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.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: do_wait: Add missing tasklist unlocking in error paths.
2013-09-20 16:41 ` Oleg Nesterov
@ 2013-09-20 17:03 ` Dave Jones
0 siblings, 0 replies; 3+ messages in thread
From: Dave Jones @ 2013-09-20 17:03 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Linux Kernel, roland, Linus Torvalds
On Fri, Sep 20, 2013 at 06:41:44PM +0200, Oleg Nesterov wrote:
> On 09/20, Dave Jones wrote:
> >
> > It looks like both 64a16caf5, and 98abed020 both introduced error paths to do_wait
> > where we miss unlocking the tasklist.
> >
> > Spotted with coverity.
>
> Not really, afaics.
>
> > --- a/kernel/exit.c
> > +++ b/kernel/exit.c
> > @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-20 17:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-20 16:37 do_wait: Add missing tasklist unlocking in error paths Dave Jones
2013-09-20 16:41 ` Oleg Nesterov
2013-09-20 17:03 ` Dave Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).