[sisyphus] q: libusb error handling bug

Alexander Bokovoy ab на altlinux.org
Вт Авг 18 07:55:28 MSD 2009


2009/8/18 Dmitry V. Levin <ldv на altlinux.org>:
> On Mon, Aug 17, 2009 at 08:49:09PM +0400, Dmitry V. Levin wrote:
>> On Sun, Aug 16, 2009 at 05:24:01PM +0300, Michael Shigorin wrote:
>> >     Здравствуйте.
>> > Несколько ранее было обнаружено, что sispmctl сегфолтится
>> > при попытке работы с USB-устройством на 2.6.18-ovz-rhel-alt7:
>> >
>> > ---
>> > $ strace sispmctl -o 1
> [...]
>
> $ valgrind sispmctl -o 1
> [...]
> ==12345== Invalid read of size 4
> ==12345==    at 0x5381B9F: usbi_log (core.c:1431)
> ==12345==    by 0x538724D: sysfs_get_device_list (linux_usbfs.c:924)
> ==12345==    by 0x5387379: op_get_device_list (linux_usbfs.c:963)
> ==12345==    by 0x5380ADD: libusb_get_device_list (core.c:560)
> ==12345==    by 0x4E29F27: usb_find_busses (in /lib64/libusb-0.1.so.4.4.4)
> ==12345==    by 0x40185B: (within /usr/bin/sispmctl)
> ==12345==    by 0x504B9DC: (below main) (in /lib64/libc-2.10.1.so)
> ==12345==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
> ==12345==
> ==12345== Process terminating with default action of signal 11 (SIGSEGV)
> ==12345==  Access not within mapped region at address 0x0
> ==12345==    at 0x5381B9F: usbi_log (core.c:1431)
> ==12345==    by 0x538724D: sysfs_get_device_list (linux_usbfs.c:924)
> ==12345==    by 0x5387379: op_get_device_list (linux_usbfs.c:963)
> ==12345==    by 0x5380ADD: libusb_get_device_list (core.c:560)
> ==12345==    by 0x4E29F27: usb_find_busses (in /lib64/libusb-0.1.so.4.4.4)
> ==12345==    by 0x40185B: (within /usr/bin/sispmctl)
> ==12345==    by 0x504B9DC: (below main) (in /lib64/libc-2.10.1.so)
>
> (gdb) bt
> #0  0x00002b7d2e6b2b9f in usbi_log (ctx=0x0, level=LOG_LEVEL_ERROR, function=0x2b7d2e6bb810 "sysfs_get_device_list",
>    format=0x2b7d2e6bb1e0 "opendir devices failed errno=%d") at core.c:1431
> #1  0x00002b7d2e6b824e in sysfs_get_device_list (ctx=0x0, _discdevs=0x7fff7cb6b050, usbfs_fallback=0x7fff7cb6b00c)
>    at os/linux_usbfs.c:924
> #2  0x00002b7d2e6b837a in op_get_device_list (ctx=0x0, _discdevs=0x7fff7cb6b050) at os/linux_usbfs.c:963
> #3  0x00002b7d2e6b1ade in libusb_get_device_list (ctx=0x0, list=0x7fff7cb6b098) at core.c:560
> #4  0x00002b7d2e15af28 in usb_find_busses () from /lib64/libusb-0.1.so.4
> #5  0x000000000040185c in ?? ()
> #6  0x00002b7d2e37c9dd in __libc_start_main () from /lib64/libc.so.6
>
> Это NULL dereference в usbi_log() из libusb.
> Вызов libusb_init() завершился неудачно, в результате чего
> usbi_default_context остался непроинициализированным.
> Остальной код libusb на это не рассчитывает.
>
> Короче говоря, надо исправить обработку ошибок в libusb.
Ok.
-- 
/ Alexander Bokovoy


Подробная информация о списке рассылки Sisyphus