chiark / gitweb /
do not allow kernel properties to be set by udev rules
authorKay Sievers <kay.sievers@vrfy.org>
Mon, 18 Jul 2011 19:19:00 +0000 (21:19 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Mon, 18 Jul 2011 19:19:00 +0000 (21:19 +0200)
udev/udev-rules.c

index 7db0767..89d9824 100644 (file)
@@ -1385,6 +1385,26 @@ static int add_rule(struct udev_rules *rules, char *line,
                                if (rule_add_key(&rule_tmp, TK_M_ENV, op, value, attr) != 0)
                                        goto invalid;
                        } else {
+                               static const char *blacklist[] = {
+                                       "ACTION",
+                                       "SUBSYSTEM",
+                                       "DEVTYPE",
+                                       "MAJOR",
+                                       "MINOR",
+                                       "DRIVER",
+                                       "IFINDEX",
+                                       "DEVNAME",
+                                       "DEVLINKS",
+                                       "DEVPATH",
+                                       "TAGS",
+                               };
+                               unsigned int i;
+
+                               for (i = 0; i < ARRAY_SIZE(blacklist); i++)
+                                       if (strcmp(attr, blacklist[i]) == 0) {
+                                               err(rules->udev, "invalid ENV attribute, '%s' can not be set %s:%u\n", attr, filename, lineno);
+                                               continue;
+                                       }
                                if (rule_add_key(&rule_tmp, TK_A_ENV, op, value, attr) != 0)
                                        goto invalid;
                        }