Fix root mounting with no mount options

The "trivial conversion" in commit cccaa5e33525 ("init: use do_mount()
instead of ksys_mount()") was totally broken, since it didn't handle the
case of a NULL mount data pointer and while I had "tested" it (and
presumably Dominik had too) that was hidden by me having options.

Change-Id: I2b1db7b68e0e398ce803da40b37595c286c97d9c
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Reported-by: Ondřej Jirman <megi@xff.cz>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Reported-and-tested-by: Borislav Petkov <bp@suse.de>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Tested-by: Eric Biggers <ebiggers@kernel.org>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Tested-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 7de7de7ca0ae0fc70515ee3154af33af75edae2c
Git-repo: https://github.com/torvalds/linux.git
[pragalla@codeaurora.org:fix merge conflicts and port changes to 5.4 kernel]
Signed-off-by: Pradeep P V K <pragalla@codeaurora.org>
This commit is contained in:
Linus Torvalds 2019-12-15 19:50:23 -08:00 committed by Pradeep P V K
parent 6dcfbd35bd
commit 67ac2d6862

View File

@ -386,17 +386,20 @@ static void __init get_fs_names(char *page)
static int __init do_mount_root(char *name, char *fs, int flags, void *data)
{
struct super_block *s;
char *data_page;
struct page *p;
char *data_page = NULL;
struct page *p = NULL;
int ret;
/* do_mount() requires a full page as fifth argument */
p = alloc_page(GFP_KERNEL);
if (!p)
return -ENOMEM;
if (data) {
/* do_mount() requires a full page as fifth argument */
p = alloc_page(GFP_KERNEL);
if (!p)
return -ENOMEM;
data_page = page_address(p);
strscpy(data_page, data, PAGE_SIZE - 1);
data_page = page_address(p);
/* zero-pad. do_mount() will make sure it's terminated */
strscpy(data_page, data, PAGE_SIZE);
}
ret = ksys_mount(name, "/root", fs, flags, data_page);
if (ret)
@ -412,7 +415,8 @@ static int __init do_mount_root(char *name, char *fs, int flags, void *data)
MAJOR(ROOT_DEV), MINOR(ROOT_DEV));
out:
put_page(p);
if (p)
put_page(p);
return ret;
}