Bug 63189 - systemd gets abort or segv by udev rule with $devpath or %p
Summary: systemd gets abort or segv by udev rule with $devpath or %p
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-05 20:52 UTC by MUNEDA Takahiro
Modified: 2013-04-17 09:10 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Proposed patch (1.30 KB, patch)
2013-04-12 10:01 UTC, Harald Hoyer
Details | Splinter Review

Description MUNEDA Takahiro 2013-04-05 20:52:16 UTC
Desription of Problem:
  systemd dies as abort or segv, then a command like reboot does not work.

  There are two behaviors of following command.

  1. A command returns immediately.

  # reboot
  Failed to open /dev/initctl: No such device or address
  Failed to talk to init daemon.
  #

  2. A command does not return forever.
  # reboot
  <does not return forever>

Versions:
  systemd-200-3.fc19.x86_64
  kernel-3.9.0-0.rc4.git0.1.fc19.x86_64

How reproducible:
  Always

Step to Reproduce:
  1. Place a udev rule file which have $devpath or %p
     The udev rule I used is following.

     localhost% cat /etc/udev/rules.d/muneda.rules
     #ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@$devpath.service"
     ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%p.service"

     Note: ABRT happens with both $devpath and %p, but SEGV happens with $devpath only so far.

  2. Generate a uevent to match the rule
     I used a following command.

     # echo online > /sys/bus/acpi/uevent

  3. systemd gets abort or segv

     abort:
     Apr  5 15:56:16 localhost systemd[1]: Failed to load device unit: Invalid argument
     Apr  5 15:56:16 localhost systemd[1]: Assertion 'os < _UNIT_ACTIVE_STATE_MAX' failed at src/core/unit.c:1323, function unit_notify(). Aborting.
     Apr  5 15:56:16 localhost systemd[1]: Caught <ABRT>, dumped core as pid 548.
     Apr  5 15:56:16 localhost systemd[1]: Freezing execution.
     Apr  5 15:56:22 localhost systemd-cgroups-agent[549]: Failed to get D-Bus connection: Failed to connect to socket /org/freedesktop/systemd1/private: Connection refused

     segv:
     Apr  5 15:39:08 localhost systemd[1]: Failed to load device unit: Invalid argument
     Apr  5 15:39:08 localhost kernel: [  184.640812] systemd[1]: segfault at 7fc4ee0b58e0 ip 00007fc7aa321fa0 sp 00007fff5e3dff58 error 4 in systemd[7fc7aa296000+f3000]
     Apr  5 15:39:08 localhost systemd[1]: Caught <SEGV>, dumped core as pid 633.
     Apr  5 15:39:08 localhost systemd[1]: Freezing execution.

Additional Info:
  When I tried following command, if returns successfully.

    # udevadm test --action=online /bus/acpi

  And the result contains following lines.

    read rules file: /etc/udev/rules.d/muneda.rules
    ...
    ACTION=online
    DEVPATH=/bus/acpi
    SUBSYSTEM=subsystem
    SYSTEMD_WANTS=muneda@/bus/acpi.service
    TAGS=:systemd:
    USEC_INITIALIZED=87854780
    unload module index
    [root@localhost ~]#

  So I suppose both reading a udev rule and replacing $devpath or %p work fine.
  The problem happens beyond those points.

Thanks,
Takahiro
Comment 1 Harald Hoyer 2013-04-12 10:01:19 UTC
Created attachment 77857 [details] [review]
Proposed patch

also sent to list
Comment 2 MUNEDA Takahiro 2013-04-14 13:59:50 UTC
(In reply to comment #1)
> Created attachment 77857 [details] [review] [review]
> Proposed patch
> 
> also sent to list

I tried V2 patch and confirmed that worked fine.
I don't see any segv, abort.

Thanks,
Takahiro
Comment 3 Harald Hoyer 2013-04-17 09:10:03 UTC
commit 003ac9d0318ce28e0b29af5440c9f28f884da04c


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.