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-next>] [day] [month] [year] [list]
Message-ID: <474F2020.7020004@rtr.ca>
Date:	Thu, 29 Nov 2007 15:25:04 -0500
From:	Mark Lord <lkml@....ca>
To:	Greg KH <gregkh@...e.de>
Cc:	Alan Stern <stern@...land.harvard.edu>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...l.org>,
	linux-usb-devel@...ts.sourceforge.net,
	Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [linux-usb-devel] [PATCH] base/class.c: prevent ooops due to
 insert/remove race (v3)

(resending .. somebody trimmed the CC: list earlier)

Greg KH wrote:
>>>> Mark Lord wrote:
>>>>> ..
>>>>>
>>>>> While doing insert/remove (quickly) tests on USB,
>>>>> I managed to trigger an Oops on 2.6.23.8 on a call
>>>>> to strlen() in make_class_name().
...

> I'll hold off on adding this patch for now.
..

Why?

Bugs that result in Oops in core code (class.c) can bite
just about any subsystem that does hotplug, and should get
prompt attention.  Or so one might think.

* * * *

Patch reproduced below for full CC:

While doing insert/remove (quickly) tests on USB, I managed to trigger
an Oops on 2.6.23.1 on the call to strlen() in make_class_name().

This patch prevents the oops, but still keeps the bug visible.

There is still the larger problem of the overall race
that caused this in the first place, but much of the rest
of the code in class.c appears to also do NULL checks to
avoid Oops'ing, so this continues the tradition.

Signed-off-by:  Mark Lord <mlord@...ox.com> ---

Patch applies to both 2.6.24 and 2.6.23.

--- old/drivers/base/class.c    2007-11-29 10:51:43.000000000 -0500
+++ linux/drivers/base/class.c    2007-11-29 13:00:15.000000000 -0500
@@ -352,9 +352,22 @@
char *make_class_name(const char *name, struct kobject *kobj)
{
    char *class_name;
+    const char *kname;
    int size;

-    size = strlen(name) + strlen(kobject_name(kobj)) + 2;
+    /* Rapidly inserting/removing a USB device (others?)
+     * can trigger an Oops on the strlen() call.
+     * Cause unknown yet, so prevent the Oops
+     * but don't mask the issue.
+     */
+    kname = kobject_name(kobj);
+    if (!kname || !name) {
+        printk(KERN_ERR "make_class_name: name=%p kname=%p\n",
+                        name, kname);
+        BUG_ON(1);
+        return NULL;
+    }
+    size = strlen(name) + strlen(kname) + 2;

    class_name = kmalloc(size, GFP_KERNEL);
    if (!class_name)

-
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