mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 05:34:13 +08:00
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>
This commit is contained in:
parent
1ad7e89940
commit
283f8fc039
@ -119,27 +119,29 @@ static dev_t devt_from_partuuid(const char *uuid_str)
|
|||||||
struct gendisk *disk;
|
struct gendisk *disk;
|
||||||
struct hd_struct *part;
|
struct hd_struct *part;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
bool clear_root_wait = false;
|
||||||
if (strlen(uuid_str) < 36)
|
char *slash;
|
||||||
goto done;
|
|
||||||
|
|
||||||
cmp.uuid = uuid_str;
|
cmp.uuid = uuid_str;
|
||||||
cmp.len = 36;
|
|
||||||
|
|
||||||
|
slash = strchr(uuid_str, '/');
|
||||||
/* Check for optional partition number offset attributes. */
|
/* Check for optional partition number offset attributes. */
|
||||||
if (uuid_str[36]) {
|
if (slash) {
|
||||||
char c = 0;
|
char c = 0;
|
||||||
/* Explicitly fail on poor PARTUUID syntax. */
|
/* Explicitly fail on poor PARTUUID syntax. */
|
||||||
if (sscanf(&uuid_str[36],
|
if (sscanf(slash + 1,
|
||||||
"/PARTNROFF=%d%c", &offset, &c) != 1) {
|
"PARTNROFF=%d%c", &offset, &c) != 1) {
|
||||||
printk(KERN_ERR "VFS: PARTUUID= is invalid.\n"
|
clear_root_wait = true;
|
||||||
"Expected PARTUUID=<valid-uuid-id>[/PARTNROFF=%%d]\n");
|
|
||||||
if (root_wait)
|
|
||||||
printk(KERN_ERR
|
|
||||||
"Disabling rootwait; root= is invalid.\n");
|
|
||||||
root_wait = 0;
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
cmp.len = slash - uuid_str;
|
||||||
|
} else {
|
||||||
|
cmp.len = strlen(uuid_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cmp.len) {
|
||||||
|
clear_root_wait = true;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = class_find_device(&block_class, NULL, &cmp,
|
dev = class_find_device(&block_class, NULL, &cmp,
|
||||||
@ -164,6 +166,13 @@ static dev_t devt_from_partuuid(const char *uuid_str)
|
|||||||
no_offset:
|
no_offset:
|
||||||
put_device(dev);
|
put_device(dev);
|
||||||
done:
|
done:
|
||||||
|
if (clear_root_wait) {
|
||||||
|
pr_err("VFS: PARTUUID= is invalid.\n"
|
||||||
|
"Expected PARTUUID=<valid-uuid-id>[/PARTNROFF=%%d]\n");
|
||||||
|
if (root_wait)
|
||||||
|
pr_err("Disabling rootwait; root= is invalid.\n");
|
||||||
|
root_wait = 0;
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user