Bug 145921 - Hald crashes with segmentation fault on write only sysfs properties (like ftdi_sio driver on 2.6.11)
Hald crashes with segmentation fault on write only sysfs properties (like ftd...
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: hal (Show other bugs)
3
All Linux
medium Severity medium
: ---
: ---
Assigned To: David Zeuthen
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-01-23 18:20 EST by Antti Andreimann
Modified: 2013-03-05 22:42 EST (History)
1 user (show)

See Also:
Fixed In Version: 0.4.7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-01-24 22:52:09 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Propsed patch: seems to work on my hardware (1.05 KB, patch)
2005-01-23 18:37 EST, Antti Andreimann
no flags Details | Diff

  None (edit)
Description Antti Andreimann 2005-01-23 18:20:50 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041111 Firefox/1.0

Description of problem:
Hal daemon crashes with segmentation fault when it encounters write only properties in sysfs.

Version-Release number of selected component (if applicable):
hal-0.4.6-1 hal-0.4.6.cvs20050121-1

How reproducible:
Always

Steps to Reproduce:
1. Install kernel 2.6.11-rc1 or 2.6.11-rc2
2. Plug in an USB serial device based on FTDI chip
  

Actual Results:  Hald crashes with segmentation fault

Expected Results:  Hald should not crash

Additional info:

The new ftdi driver includes a property called event_char that is write only.
Reading from this device gives EPERM eg:
cat: /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.5/event_char: Permission denied
Hald does not like this at all.
Here is a gdb backtrace:
<...>
01:01:50.676 [I] hald.c:81: Added device to GDL; udi=/org/freedesktop/Hal/devices/usb_usb_device_499_1009_101_-1_noserial_0
01:01:50.676 [I] linux/osspec.c:795: handling /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.5 usb

Program received signal SIGSEGV, Segmentation fault.
0x0805dd62 in usb_device_pre_process (self=0x807a700, d=0x8284858,
    sysfs_path=0x8284380 "/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.5",
    device=0x82843c8) at linux/usb_bus_device.c:826
826                     len = strlen (cur->value);
(gdb) bt
#0  0x0805dd62 in usb_device_pre_process (self=0x807a700, d=0x8284858,
    sysfs_path=0x8284380 "/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.5",
    device=0x82843c8) at linux/usb_bus_device.c:826
#1  0x0805bcf8 in bus_device_got_parent (store=0x0, parent=0xbfffe530,
    user_data=0x825df08) at linux/bus_device.c:202
#2  0x0805bf34 in bus_device_visit (self=0x8236540,
    path=0xbfffe970 "/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.5",
    device=0x8283c48) at linux/bus_device.c:134
#3  0x08059c61 in add_device (given_sysfs_path=0x0, subsystem=0x80c65e0 "usb",
    msg=0x0) at linux/osspec.c:1077
#4  0x0805ae67 in process_coldplug_list () at linux/osspec.c:796
#5  0x00cdf347 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#6  0x00cf5ae1 in g_signal_has_handler_pending ()
   from /usr/lib/libgobject-2.0.so.0
#7  0x00cf6cbc in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#8  0x00cf6f5a in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#9  0x08050f8c in hal_device_store_add (store=0x80ca790, device=0x8249e20)
    at device_store.c:183
#10 0x0805bc08 in bus_device_move_from_tdl_to_gdl (device=0x8249e20,
    user_data=0x8257840) at linux/bus_device.c:161
#11 0x00cf73ae in g_cclosure_marshal_VOID__VOID ()
   from /usr/lib/libgobject-2.0.so.0
#12 0x00cdf347 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#13 0x00cf5ae1 in g_signal_has_handler_pending ()
   from /usr/lib/libgobject-2.0.so.0
#14 0x00cf6cbc in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#15 0x00cf6f5a in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#16 0x0804ed99 in hal_device_callouts_finished (device=0x0) at device.c:1101
#17 0x0804c9bf in iochn_data (source=0x0, condition=G_IO_IN, user_data=0x0)
    at callout.c:192
#18 0x00c7b9c7 in g_vasprintf () from /usr/lib/libglib-2.0.so.0
#19 0x00c577bb in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#20 0x00c59242 in g_main_context_acquire () from /usr/lib/libglib-2.0.so.0
#21 0x00c594ef in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#22 0x080520e4 in main (argc=3, argv=0xbffff754) at hald.c:513
#23 0x007fbe33 in __libc_start_main () from /lib/tls/libc.so.6
#24 0x0804c151 in _start ()
(gdb) print cur->value
$1 = 0x0
(gdb) print cur->len
$3 = 0
(gdb) print cur->name
$4 = "event_char", '\0' <repeats 39 times>
Comment 1 Antti Andreimann 2005-01-23 18:37:44 EST
Created attachment 110112 [details]
Propsed patch: seems to work on my hardware

Removed blind strlen-s to data pointer and used len property instead.
NOTE: I only audited the crashing function not the whole code
Comment 2 David Zeuthen 2005-01-24 16:38:46 EST
Thanks for the patch; looks good. I've also applied this fix other places where
we read sysfs files. Please test these RPM's

 http://people.redhat.com/davidz/hal-cvs20050124/

to see if I've got the fix right. Thanks.
Comment 3 Antti Andreimann 2005-01-24 20:08:50 EST
Works, thanx.

Note You need to log in before you can comment on or make changes to this bug.