Skip to contentSkip to conversation

Driver core: warn when userspace writes to the uevent file in a non-supported way

DISCUSSION Alan Cox 1 participant 2 messages Apr 27, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Alan Cox

author
#1 lore raw
Quoted 16 lines

In the future we will allow the uevent type to be written to the uevent file to trigger the different types of uevents. But for now, as we only support the ADD event, warn if userspace tries to write anything else to this file.

---
 drivers/base/core.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/base/core.c +0 -0
index 72c6ee5..f69305c 100644

drivers/base/core.c out: · line 301

Quoted 6 lines
drivers/base/core.c +3 -0
@@ -296,6 +296,9 @@ out:
 static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
 			    const char *buf, size_t count)
 {
+	if (memcmp(buf, "add", 3) != 0)
+		dev_err(dev, "uevent: unsupported action-string; this will "
+			"be ignored in a future kernel version");

Warnings good, lack of rate limiting extremely bad indeed.

author
#2 lore raw
In reply to a message not in the archive

drivers/base/core.c out: · line 304

Quoted 12 lines
drivers/base/core.c +3 -0
@@ -296,6 +296,9 @@ out:
 static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
 			    const char *buf, size_t count)
 {
+	if (memcmp(buf, "add", 3) != 0)
+		dev_err(dev, "uevent: unsupported action-string; this will "
+			"be ignored in a future kernel version");
 	kobject_uevent(&dev->kobj, KOBJ_ADD);
 	return count;
 }

And checking for "add" without actually checking if count >= 3 is very ugly style indeed. Not afaict any kind of security risk as the next 3 bytes are always going to be readable