Skip to content

Commit

Permalink
init: stricter checking of major:minor root= values
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Ehrenberg authored and snitm committed Apr 15, 2015
1 parent e6e20a7 commit 283e7ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion init/do_mounts.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ dev_t name_to_dev_t(const char *name)

if (strncmp(name, "/dev/", 5) != 0) {
unsigned maj, min;
char dummy;

if (sscanf(name, "%u:%u", &maj, &min) == 2) {
if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) {
res = MKDEV(maj, min);
if (maj != MAJOR(res) || min != MINOR(res))
goto fail;
Expand Down

0 comments on commit 283e7ad

Please sign in to comment.