Skip to content

Commit 283f8fc

Browse files
nvswarrenaxboe
authored andcommitted
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 <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Will Drewry <[email protected]> Cc: Kay Sievers <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 1ad7e89 commit 283f8fc

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

init/do_mounts.c

+22-13
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,29 @@ static dev_t devt_from_partuuid(const char *uuid_str)
119119
struct gendisk *disk;
120120
struct hd_struct *part;
121121
int offset = 0;
122-
123-
if (strlen(uuid_str) < 36)
124-
goto done;
122+
bool clear_root_wait = false;
123+
char *slash;
125124

126125
cmp.uuid = uuid_str;
127-
cmp.len = 36;
128126

127+
slash = strchr(uuid_str, '/');
129128
/* Check for optional partition number offset attributes. */
130-
if (uuid_str[36]) {
129+
if (slash) {
131130
char c = 0;
132131
/* Explicitly fail on poor PARTUUID syntax. */
133-
if (sscanf(&uuid_str[36],
134-
"/PARTNROFF=%d%c", &offset, &c) != 1) {
135-
printk(KERN_ERR "VFS: PARTUUID= is invalid.\n"
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;
132+
if (sscanf(slash + 1,
133+
"PARTNROFF=%d%c", &offset, &c) != 1) {
134+
clear_root_wait = true;
141135
goto done;
142136
}
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;
143145
}
144146

145147
dev = class_find_device(&block_class, NULL, &cmp,
@@ -164,6 +166,13 @@ static dev_t devt_from_partuuid(const char *uuid_str)
164166
no_offset:
165167
put_device(dev);
166168
done:
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+
}
167176
return res;
168177
}
169178
#endif

0 commit comments

Comments
 (0)