Skip to content

Commit 283e7ad

Browse files
Dan Ehrenbergsnitm
authored andcommitted
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>
1 parent e6e20a7 commit 283e7ad

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

init/do_mounts.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ dev_t name_to_dev_t(const char *name)
226226

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

230-
if (sscanf(name, "%u:%u", &maj, &min) == 2) {
231+
if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) {
231232
res = MKDEV(maj, min);
232233
if (maj != MAJOR(res) || min != MINOR(res))
233234
goto fail;

0 commit comments

Comments
 (0)