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] [day] [month] [year] [list]
Date:	Tue, 4 Dec 2007 23:31:51 +0100
From:	Matthias Kaehlcke <matthias.kaehlcke@...il.com>
To:	Daniel Walker <dwalker@...sta.com>
Cc:	gregkh@...e.de, linux-usb-users@...ts.sourceforge.net,
	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>, mingo@...e.hu
Subject: Re: [PATCH] USB testing driver: convert dev->sem to mutex

El Tue, Dec 04, 2007 at 11:09:02AM -0800 Daniel Walker ha dit:

> On Tue, 2007-12-04 at 17:55 +0100, Matthias Kaehlcke wrote:
> > @@ -1990,7 +1991,7 @@ static void usbtest_disconnect (struct
> > usb_interface *intf)
> >  {
> >         struct usbtest_dev      *dev = usb_get_intfdata (intf);
> >  
> > -       down (&dev->sem);
> > +       mutex_lock(&dev->lock);
> >  
> >         usb_set_intfdata (intf, NULL);
> >         dev_dbg (&intf->dev, "disconnect\n"); 
> 
> This looks like a bit of an anomaly.. The code that isn't shown above is
> the "kfree(dev)" .. So this isn't legal since it's freeing a locked
> mutex. Here's a excerpt from the comment above mutex_lock(),
> 
>  * The mutex must later on be released by the same task that
>  * acquired it. Recursive locking is not allowed. The task
>  * may not exit without first unlocking the mutex. Also, kernel
>  * memory where the mutex resides mutex must not be freed with
>  * the mutex still locked. The mutex must first be initialized
>  * (or statically defined) before it can be locked. memset()-ing
>  * the mutex to 0 is not allowed.

you're absolutely right that freeing a locked mutex isn't a good idea

thanks for pointing it out!

-- 
Matthias Kaehlcke
Linux System Developer
Barcelona

                Don't walk behind me, I may not lead
             Don't walk in front of me, I may not follow
                Just walk beside me and be my friend
                          (Albert Camus)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
--
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