lkml.org 
[lkml]   [2015]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 2/3] init: Stricter checking of major:minor root= values
Date
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 patch is to help in unifying dm's interpretation of
its block device argument with the interpretation in other parts of
the kernel. dm rejects malformed major:minor pairs, and it seems
reasonable that root= could reject them as well.

Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
---
init/do_mounts.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/init/do_mounts.c b/init/do_mounts.c
index 4b2daf1..24f359f 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -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;
--
2.2.0.rc0.207.ga3a616c


\
 
 \ /
  Last update: 2015-02-11 00:41    [W:0.247 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site