From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux-hotplug@vger.kernel.org
Subject: udevd: be more careful when matching against parents
Date: Sat, 01 Nov 2008 16:10:04 +0000 [thread overview]
Message-ID: <490C7F5C.6050005@tuffmail.co.uk> (raw)
I'm worried about what will happen with things like
KERNELS="*" # pointless rule
KERNELS="doesnt-match" # another pointless rule
Since TK_RULE < TK_M_PARENTS_MAX, we will try to match all three tokens
against parents of the current device. I can't think of a bad case,
but it's not exactly good either.
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
diff --git a/udev/udev-rules.c b/udev/udev-rules.c
index f6cc45b..a0c9926 100644
--- a/udev/udev-rules.c
+++ b/udev/udev-rules.c
@@ -93,6 +93,7 @@ enum token_type {
TK_M_WAITFOR, /* val */
TK_M_ATTR, /* val, attr */
+ TK_M_PARENTS_MIN,
TK_M_KERNELS, /* val */
TK_M_SUBSYSTEMS, /* val */
TK_M_DRIVERS, /* val */
@@ -146,6 +147,7 @@ static const char *token_str[] = {
[TK_M_WAITFOR] = "M WAITFOR",
[TK_M_ATTR] = "M ATTR",
+ [TK_M_PARENTS_MIN] = "M PARENTS_MIN",
[TK_M_KERNELS] = "M KERNELS",
[TK_M_SUBSYSTEMS] = "M SUBSYSTEMS",
[TK_M_DRIVERS] = "M DRIVERS",
@@ -806,6 +808,7 @@ static int rule_add_token(struct rule_tmp *rule_tmp, enum token_type type,
token->key.event_timeout = *(int *)data;
break;
case TK_RULE:
+ case TK_M_PARENTS_MIN:
case TK_M_PARENTS_MAX:
case TK_M_MAX:
case TK_END:
@@ -943,6 +946,7 @@ static void dump_token(struct udev_rules *rules, struct token *token)
case TK_END:
dbg(rules->udev, "* %s\n", token_str[type]);
break;
+ case TK_M_PARENTS_MIN:
case TK_M_PARENTS_MAX:
case TK_M_MAX:
case TK_UNSET:
@@ -1937,7 +1941,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
/* get whole sequence of parent matches */
next = cur;
- while (next->type < TK_M_PARENTS_MAX)
+ while (next->type > TK_M_PARENTS_MIN && next->type < TK_M_PARENTS_MAX)
next++;
/* loop over parents */
@@ -2321,6 +2325,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
case TK_END:
break;
+ case TK_M_PARENTS_MIN:
case TK_M_PARENTS_MAX:
case TK_M_MAX:
case TK_UNSET:
next reply other threads:[~2008-11-01 16:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-01 16:10 Alan Jenkins [this message]
2008-11-01 16:36 ` udevd: be more careful when matching against parents Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=490C7F5C.6050005@tuffmail.co.uk \
--to=alan-jenkins@tuffmail.co.uk \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.