lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 02 Feb 2012 08:45:01 +0100
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Dmitry Antipov <dmitry.antipov@...aro.org>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: Module/kthread/printk question/problem

Le jeudi 02 février 2012 à 10:13 +0400, Dmitry Antipov a écrit :
> On 02/01/2012 09:16 PM, Eric Dumazet wrote:
> 
> >> I realize this, but there was a second part of the question: what's the
> >> better way to ensure that all test/X threads are really gone at some point of
> >> testmod_exit()?
> >>
> >
> > You could use kthread_stop()
> >
> > This way you can control all your kernel threads really exited before
> > module cleanup.
> 
> Hm... if I try something like:
> 
> static void __exit testmod_exit(void)
> {
> 	int i;
> 
> 	wait_for_completion(&done);
> 	for (i = 0; i < nrthreads; i++)
> 		kthread_stop(threads[i]);
> 	kfree(threads);
> }
> 
> typical result is:


> I suppose that __put_task_struct() was called for the thread when is 'partially dead'
> (because it's somewhere in do_exit() called by kthread() after returning from thread's
> function), but not 'dead enough' to finalize it with free_task().
> 
> So, the question is still open.
> 

Really you need to better understand how all this works.

Remove the wait_for_completion(), this brings nothing at all, as you
already discovered.

Then you need cooperation from worker threads : they must wait for
kthread_should_stop(), or else your kthread_stop(arg) pass an already
freed "arg" memory block.

Take the time to read kernel/kthread.c and function kthread_stop()



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ