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]
Message-Id: <20080805092209.830f5d0a.akpm@linux-foundation.org>
Date:	Tue, 5 Aug 2008 09:22:09 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Matthew Wilcox <matthew@....cx>
Cc:	Linus Torvalds <torvalds@...uxfoundation.org>,
	Andrew Morton <akpm@...uxfoundation.org>,
	linux-kernel@...r.kernel.org, Rusty Russell <rusty@...tcorp.com.au>
Subject: Re: [PATCH] Make kthread_stop() not oops when passed a bad pointer

On Tue, 5 Aug 2008 07:55:59 -0600 Matthew Wilcox <matthew@....cx> wrote:

> 
> Due to some botched error handling code in a driver I was writing, I
> recently called kthread_stop(NULL).  It's terribly exciting to discover
> that you've just oopsed while holding a mutex that's required in order
> to shut down.  Make kthread_stop a little more robust against numbskulls
> like me.
> 
> Signed-off-by: Matthew Wilcox <willy@...ux.intel.com>
> 
> diff --git a/kernel/kthread.c b/kernel/kthread.c
> index 96cff2f..06c3477 100644
> --- a/kernel/kthread.c
> +++ b/kernel/kthread.c
> @@ -201,6 +201,9 @@ int kthread_stop(struct task_struct *k)
>  {
>  	int ret;
>  
> +	if (!k || IS_ERR(k))
> +		return -EINVAL;
> +
>  	mutex_lock(&kthread_stop_lock);
>  

hrm.

a) as this is a programming error, the programmer would like it not
   to be hidden.  A WARN_ON() would address that.

b) there are many instances of

	if (p)
		kthread_stop(p);

   which could now be simplified to

	kthread_stop(p);

c) a) and b) are incompatible.
--
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