possible race condition in kdbus:domain

Kay Sievers kay at vrfy.org
Wed May 7 15:20:16 PDT 2014


On Thu, May 8, 2014 at 12:00 AM, John de la Garza <john at jjdev.com> wrote:
> kdbus_domain_new() calls device_register which sends a message to udev
> to create the device file which is done asynchronously by udev.

Udev, since years, has no code to create device nodes, it can only
create symlinks to device nodes. Device nodes are created in the
devtmpfs filesystem by the kernel.

> If one
> calls close on the file descriptor immediately after creating a domain
> the close call calls kdbus_domain_disconnect which calls device_unregister
> before device_register's udev call to create the file finished resulting
> in the file not getting removed from /dev/kdbus.

The driver core, creating destroying devices and devtmpfs are all
synchronous operations, there are no async tasks involved.

> Adding msleep(5) fixes this in some cases do does msleep(0).
>
> I'm thinking this may not always work and kdbus_domain_new should
> explicitly wait till the file shows up in /dev before returning.
>
> Is it safe to assume udev will finish in a fixed time or should
> it be checked?

Just mount devtmpfs at /dev, and forget about all the hacks. :)

Kay


More information about the dbus mailing list