Segmentation fault in eglibc if usbfs_path is NULL and usbfs_get_device_list get called afterwards

Bug #1202912 reported by Unknown | zD.
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
libusbx (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Basically this bug exist from 1.0.12 to 1.0.16 (so this may affect Saucy as well)

Tested under Hyper-V Ubuntu 13.04 (Raring) with linux-virtual kernel and targeted driver (using netinstall iso).

So I have got this bug when I was running the steam client binary (yes, I know that this may also be a problem created by steam client itself as it ignores the value returned by op_init, but I think it would be to make the libusbx to become a fail proof library. And I will report this bug to valve as well) in Hyper VM (Raring), without any predefined usbfs path on it.

As there is no dbg build for libusb-1.0.12 atm, I have built one on my own and here is what I have got with gdb attached to steam client binary.
-------------------------------------------------------------------------------------------------------------------------------------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xecf00b40 (LWP 40013)]
__opendirat (dfd=dfd@entry=-100, name=name@entry=0x0)
    at ../sysdeps/posix/opendir.c:90
90 ../sysdeps/posix/opendir.c: No such file or directory.
(gdb) frame 2
#2 0xec2e460e in usbfs_get_device_list (_discdevs=0xeceffddc, ctx=0xebd014c8)
    at os/linux_usbfs.c:1088
1088 DIR *buses = opendir(usbfs_path);
-------------------------------------------------------------------------------------------------------------------------------------------
(Frame 1 is simply a opendir function which passed the NULL pointer to opendirat in eglibc)

Afterwards, I have recompiled the libusb 1.0.12 with following lines added to the usbfs_get_device_list function.
-------------------------------------------------------------------------------------------------------------------------------------------
static int usbfs_get_device_list(struct libusb_context *ctx,
 struct discovered_devs **_discdevs)
{
 if (!usbfs_path) {
  usbi_err(ctx, "could not find usbfs");
  return LIBUSB_ERROR_OTHER;
 }
 struct dirent *entry;
 DIR *buses = opendir(usbfs_path);
-------------------------------------------------------------------------------------------------------------------------------------------
And steam client is working like a charm again.

Therefore I want to ask can you guys consider to add a check within usbfs_get_device_list or not?

Best regards,
UnknownzD

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in libusbx (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.