possible race condition in kdbus:domain
John de la Garza
john at jjdev.com
Wed May 7 15:00:36 PDT 2014
kdbus_domain_new() calls device_register which sends a message to udev
to create the device file which is done asynchronously by udev. 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.
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?
Or may there is another way to address this... any ideas?
Signed-off-by: John de la Garza <john at jjdev.com>
---
domain.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/domain.c b/domain.c
index ee77f36..f53d18b 100644
--- a/domain.c
+++ b/domain.c
@@ -19,6 +19,7 @@
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
+#include <linux/delay.h>
#include "bus.h"
#include "defaults.h"
@@ -356,6 +357,10 @@ int kdbus_domain_new(struct kdbus_domain *parent, const char *name,
mutex_unlock(&parent->lock);
*domain = d;
+
+ /* allow udev time to create file */
+ msleep(5);
+
return 0;
exit_unlock:
--
1.7.10.4
More information about the dbus
mailing list