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: <20090526141552.507f8821.akpm@linux-foundation.org>
Date:	Tue, 26 May 2009 14:15:52 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc:	linux-kernel@...r.kernel.org, greg@...ah.com,
	Kay Sievers <kay.sievers@...y.org>, Tejun Heo <tj@...nel.org>
Subject: Re: [PATCH] devres: WARN() and return, don't crash on device_del()
 of uninitialized device

On Mon, 25 May 2009 16:53:31 +1000
Benjamin Herrenschmidt <benh@...nel.crashing.org> wrote:

> I just debugged an obscure crash caused by a device_del() of a all NULL'd
> out struct device (in usb-serial) and found that a patch like this one would
> have saved me time (in addition to improved chances of a bug report from
> users hitting similar driver bugs).
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@...nel.crashing.org>
> ---
> 
>  drivers/base/devres.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> --- linux-work.orig/drivers/base/devres.c	2009-05-25 16:43:46.000000000 +1000
> +++ linux-work/drivers/base/devres.c	2009-05-25 16:46:36.000000000 +1000
> @@ -428,6 +428,11 @@ int devres_release_all(struct device *de
>  {
>  	unsigned long flags;
>  
> +	/* Looks like an uninitialized device structure */
> +	if (dev->devres_head.next == NULL) {
> +		WARN(1);
> +		return -ENODEV;
> +	}
>  	spin_lock_irqsave(&dev->devres_lock, flags);
>  	return release_nodes(dev, dev->devres_head.next, &dev->devres_head,
>  			     flags);

This could be coded a little more neatly as:

	/* Looks like an uninitialized device structure */
	if (WARN_ON(dev->devres_head.next == NULL))
		return -ENODEV;

--
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