aboutsummaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-11-08 19:12:27 -0500
committerJens Axboe <axboe@kernel.dk>2012-11-23 08:28:56 -0500
commit283f8fc03927b0ef42a2faa60a0df5ec8c612edb (patch)
tree4258ba54ada02d6f9d7291a3b2b0eac454e1bc08 /init
parent1ad7e89940d5ac411928189e1a4a01901dbf590f (diff)
init: reduce PARTUUID min length to 1 from 36
Reduce the minimum length for a root=PARTUUID= parameter to be considered valid from 36 to 1. EFI/GPT partition UUIDs are always exactly 36 characters long, hence the previous limit. However, the next patch will support DOS/MBR UUIDs too, which have a different, shorter, format. Instead of validating any particular length, just ensure that at least some non-empty value was given by the user. Also, consider a missing UUID value to be a parsing error, in the same vein as if /PARTNROFF exists and can't be parsed. As such, make both error cases print a message and disable rootwait. Convert to pr_err while we're at it. Signed-off-by: Stephen Warren <swarren@nvidia.com> Cc: Tejun Heo <tj@kernel.org> Cc: Will Drewry <wad@chromium.org> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'init')
-rw-r--r--init/do_mounts.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/init/do_mounts.c b/init/do_mounts.c
index b28ec5819325..c950d7c93f98 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -119,27 +119,29 @@ static dev_t devt_from_partuuid(const char *uuid_str)
119 struct gendisk *disk; 119 struct gendisk *disk;
120 struct hd_struct *part; 120 struct hd_struct *part;
121 int offset = 0; 121 int offset = 0;
122 122 bool clear_root_wait = false;
123 if (strlen(uuid_str) < 36) 123 char *slash;
124 goto done;
125 124
126 cmp.uuid = uuid_str; 125 cmp.uuid = uuid_str;
127 cmp.len = 36;
128 126
127 slash = strchr(uuid_str, '/');
129 /* Check for optional partition number offset attributes. */ 128 /* Check for optional partition number offset attributes. */
130 if (uuid_str[36]) { 129 if (slash) {
131 char c = 0; 130 char c = 0;
132 /* Explicitly fail on poor PARTUUID syntax. */ 131 /* Explicitly fail on poor PARTUUID syntax. */
133 if (sscanf(&uuid_str[36], 132 if (sscanf(slash + 1,
134 "/PARTNROFF=%d%c", &offset, &c) != 1) { 133 "PARTNROFF=%d%c", &offset, &c) != 1) {
135 printk(KERN_ERR "VFS: PARTUUID= is invalid.\n" 134 clear_root_wait = true;
136 "Expected PARTUUID=<valid-uuid-id>[/PARTNROFF=%%d]\n");
137 if (root_wait)
138 printk(KERN_ERR
139 "Disabling rootwait; root= is invalid.\n");
140 root_wait = 0;
141 goto done; 135 goto done;
142 } 136 }
137 cmp.len = slash - uuid_str;
138 } else {
139 cmp.len = strlen(uuid_str);
140 }
141
142 if (!cmp.len) {
143 clear_root_wait = true;
144 goto done;
143 } 145 }
144 146
145 dev = class_find_device(&block_class, NULL, &cmp, 147 dev = class_find_device(&block_class, NULL, &cmp,
@@ -164,6 +166,13 @@ static dev_t devt_from_partuuid(const char *uuid_str)
164no_offset: 166no_offset:
165 put_device(dev); 167 put_device(dev);
166done: 168done:
169 if (clear_root_wait) {
170 pr_err("VFS: PARTUUID= is invalid.\n"
171 "Expected PARTUUID=<valid-uuid-id>[/PARTNROFF=%%d]\n");
172 if (root_wait)
173 pr_err("Disabling rootwait; root= is invalid.\n");
174 root_wait = 0;
175 }
167 return res; 176 return res;
168} 177}
169#endif 178#endif