mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] exit signals: use of uninitialized field notify_count
@ 2008-08-26 22:14 Steve VanDeBogart
  2008-08-27  8:01 ` Ingo Molnar
  0 siblings, 1 reply; 6+ messages in thread
From: Steve VanDeBogart @ 2008-08-26 22:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar

task->signal->notify_count is only initialized if
task->signal->group_exit_task is not NULL.  Reorder a conditional so
that uninitialised memory is not used.  Found by Valgrind.

Signed-off-by: Steve VanDeBogart <vandebo-lkml@nerdbox.net>
---

Index: linux/kernel/exit.c
===================================================================
--- linux.orig/kernel/exit.c	2008-08-06 09:19:01.000000000 -0700
+++ linux/kernel/exit.c	2008-08-23 15:21:34.000000000 -0700
@@ -883,8 +883,8 @@

  	/* mt-exec, de_thread() is waiting for us */
  	if (thread_group_leader(tsk) &&
-	    tsk->signal->notify_count < 0 &&
-	    tsk->signal->group_exit_task)
+	    tsk->signal->group_exit_task &&
+	    tsk->signal->notify_count < 0)
  		wake_up_process(tsk->signal->group_exit_task);

  	write_unlock_irq(&tasklist_lock);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] exit signals: use of uninitialized field notify_count
  2008-08-26 22:14 [PATCH] exit signals: use of uninitialized field notify_count Steve VanDeBogart
@ 2008-08-27  8:01 ` Ingo Molnar
  2008-08-27 16:11   ` Oleg Nesterov
  2008-08-28  0:27   ` Steve VanDeBogart
  0 siblings, 2 replies; 6+ messages in thread
From: Ingo Molnar @ 2008-08-27  8:01 UTC (permalink / raw)
  To: Steve VanDeBogart; +Cc: linux-kernel, Roland McGrath, Oleg Nesterov


* Steve VanDeBogart <vandebo-lkml@NerdBox.Net> wrote:

> task->signal->notify_count is only initialized if
> task->signal->group_exit_task is not NULL.  Reorder a conditional so
> that uninitialised memory is not used.  Found by Valgrind.
>
> Signed-off-by: Steve VanDeBogart <vandebo-lkml@nerdbox.net>

Applied the commit below to tip/core/urgent, thanks. Roland/Oleg, do you 
concur with the fix?

nice find btw. - are you running Valgrind on UML?

	Ingo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] exit signals: use of uninitialized field notify_count
  2008-08-27  8:01 ` Ingo Molnar
@ 2008-08-27 16:11   ` Oleg Nesterov
  2008-08-28  0:58     ` Steve VanDeBogart
  2008-08-28  0:27   ` Steve VanDeBogart
  1 sibling, 1 reply; 6+ messages in thread
From: Oleg Nesterov @ 2008-08-27 16:11 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steve VanDeBogart, linux-kernel, Roland McGrath

On 08/27, Ingo Molnar wrote:
> 
> * Steve VanDeBogart <vandebo-lkml@NerdBox.Net> wrote:
> 
> > task->signal->notify_count is only initialized if
> > task->signal->group_exit_task is not NULL.  Reorder a conditional so
> > that uninitialised memory is not used.  Found by Valgrind.
> >
> > Signed-off-by: Steve VanDeBogart <vandebo-lkml@nerdbox.net>
> 
> Applied the commit below to tip/core/urgent, thanks. Roland/Oleg, do you 
> concur with the fix?

Inho, very nice cleanup.

Minor comment. As Roland pointed out, it makes sense to initialize
the whole signal_struct explicitely, perhaps copy_signal() should
just use zalloc. In that case we don't need to check ->group_exit_task
at all, the same for __exit_signal().

Thanks Steve! and what do you think about the above?

Oleg.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] exit signals: use of uninitialized field notify_count
  2008-08-27  8:01 ` Ingo Molnar
  2008-08-27 16:11   ` Oleg Nesterov
@ 2008-08-28  0:27   ` Steve VanDeBogart
  1 sibling, 0 replies; 6+ messages in thread
From: Steve VanDeBogart @ 2008-08-28  0:27 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Roland McGrath, Oleg Nesterov

On Wed, 27 Aug 2008, Ingo Molnar wrote:

>
> * Steve VanDeBogart <vandebo-lkml@NerdBox.Net> wrote:
>
>> task->signal->notify_count is only initialized if
>> task->signal->group_exit_task is not NULL.  Reorder a conditional so
>> that uninitialised memory is not used.  Found by Valgrind.
>>
>> Signed-off-by: Steve VanDeBogart <vandebo-lkml@nerdbox.net>
>
> Applied the commit below to tip/core/urgent, thanks. Roland/Oleg, do you
> concur with the fix?
>
> nice find btw. - are you running Valgrind on UML?

Thanks.  Yes, I am running Valgrind on UML.  I revisited the previous 
patches that allowed it and tried to remove any unnecessary changes.
The patches and a recipe on how to make it work can be found on the
UML wiki: http://uml.jfdi.org/uml/Wiki.jsp?page=ValgrindingUML

I'll stir up trouble by posting the kernel patches on lkml after a
little more cleanup.

--
Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] exit signals: use of uninitialized field notify_count
  2008-08-27 16:11   ` Oleg Nesterov
@ 2008-08-28  0:58     ` Steve VanDeBogart
  2008-08-28 12:58       ` Oleg Nesterov
  0 siblings, 1 reply; 6+ messages in thread
From: Steve VanDeBogart @ 2008-08-28  0:58 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Ingo Molnar, linux-kernel, Roland McGrath

On Wed, 27 Aug 2008, Oleg Nesterov wrote:

>> * Steve VanDeBogart <vandebo-lkml@NerdBox.Net> wrote:
>>
>>> task->signal->notify_count is only initialized if
>>> task->signal->group_exit_task is not NULL.  Reorder a conditional so
>>> that uninitialised memory is not used.  Found by Valgrind.
>
> Minor comment. As Roland pointed out, it makes sense to initialize
> the whole signal_struct explicitely, perhaps copy_signal() should
> just use zalloc. In that case we don't need to check ->group_exit_task
> at all, the same for __exit_signal().
>
> Thanks Steve! and what do you think about the above?

It looks like that would work.  Seems that
sig->count == 0 && sig->group_exit_task != NULL can never be true.
If it does work, a lot of initialization in copy_signal() can be
removed and it would reduce the chances that a similar problem would be
reintroduced.  I would submit a patch, but I'm not sure how to trigger
those code paths in order to test it.

--
Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] exit signals: use of uninitialized field notify_count
  2008-08-28  0:58     ` Steve VanDeBogart
@ 2008-08-28 12:58       ` Oleg Nesterov
  0 siblings, 0 replies; 6+ messages in thread
From: Oleg Nesterov @ 2008-08-28 12:58 UTC (permalink / raw)
  To: Steve VanDeBogart; +Cc: Ingo Molnar, linux-kernel, Roland McGrath

On 08/27, Steve VanDeBogart wrote:
>
> It looks like that would work.  Seems that
> sig->count == 0 && sig->group_exit_task != NULL can never be true.
> If it does work, a lot of initialization in copy_signal() can be
> removed and it would reduce the chances that a similar problem would be
> reintroduced.  I would submit a patch, but I'm not sure how to trigger
> those code paths in order to test it.

I'd suggest to make 2 patches. The first one adds "->notify_count = 0"
to copy_signal() and removes "->group_exit_task != NULL" checks. The
second one changes copy_signal() to use zalloc.

BTW, I forgot to mention that you can kill the "thread_group_leader()"
check in exit_notify() too.

Oleg.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-08-28 12:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-26 22:14 [PATCH] exit signals: use of uninitialized field notify_count Steve VanDeBogart
2008-08-27  8:01 ` Ingo Molnar
2008-08-27 16:11   ` Oleg Nesterov
2008-08-28  0:58     ` Steve VanDeBogart
2008-08-28 12:58       ` Oleg Nesterov
2008-08-28  0:27   ` Steve VanDeBogart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®