diff options
author | Dan Ehrenberg <dehrenberg@chromium.org> | 2015-02-10 18:20:50 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2015-04-15 12:10:19 -0400 |
commit | 283e7ad0241155710f99a9f39d13313a53336926 (patch) | |
tree | 88f730b39f4438648f3da982a596fcfa5f3ce70e | |
parent | e6e20a7a5f3f49bfee518d5c6849107398d83912 (diff) |
init: stricter checking of major:minor root= values
In the kernel command-line, previously, root=1:2jakshflaksjdhfa would
be accepted and interpreted just like root=1:2. This patch adds
stricter checking so that additional characters after major:minor are
rejected by root=.
The goal of this change is to help in unifying DM's interpretation of
its block device argument by using existing kernel code (name_to_dev_t).
But DM rejects malformed major:minor pairs, it seems reasonable for
root= to reject them as well.
Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r-- | init/do_mounts.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/init/do_mounts.c b/init/do_mounts.c index c16adfbe4ad6..8369ffa5f33d 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c | |||
@@ -226,8 +226,9 @@ dev_t name_to_dev_t(const char *name) | |||
226 | 226 | ||
227 | if (strncmp(name, "/dev/", 5) != 0) { | 227 | if (strncmp(name, "/dev/", 5) != 0) { |
228 | unsigned maj, min; | 228 | unsigned maj, min; |
229 | char dummy; | ||
229 | 230 | ||
230 | if (sscanf(name, "%u:%u", &maj, &min) == 2) { | 231 | if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) { |
231 | res = MKDEV(maj, min); | 232 | res = MKDEV(maj, min); |
232 | if (maj != MAJOR(res) || min != MINOR(res)) | 233 | if (maj != MAJOR(res) || min != MINOR(res)) |
233 | goto fail; | 234 | goto fail; |