Skip to content

Commit

Permalink
initrd: use do_mount() instead of ksys_mount()
Browse files Browse the repository at this point in the history
All three calls to ksys_mount() in initrd-related kernel code can
be switched over to do_mount():
- the first and third arguments are const strings in the kernel,
  and do not need to be copied over from userspace;
- the fifth argument is NULL, and therefore no page needs to be,
  copied over from userspace;
- the second and fourth argument are passed through anyway.

Signed-off-by: Dominik Brodowski <[email protected]>
  • Loading branch information
Dominik Brodowski committed Dec 12, 2019
1 parent 5e787db commit d4440aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions init/do_mounts_initrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
ksys_dup(0);
/* move initrd over / and chdir/chroot in initrd root */
ksys_chdir("/root");
ksys_mount(".", "/", NULL, MS_MOVE, NULL);
do_mount(".", "/", NULL, MS_MOVE, NULL);
ksys_chroot(".");
ksys_setsid();
return 0;
Expand Down Expand Up @@ -89,7 +89,7 @@ static void __init handle_initrd(void)
current->flags &= ~PF_FREEZER_SKIP;

/* move initrd to rootfs' /old */
ksys_mount("..", ".", NULL, MS_MOVE, NULL);
do_mount("..", ".", NULL, MS_MOVE, NULL);
/* switch root and cwd back to / of rootfs */
ksys_chroot("..");

Expand All @@ -103,7 +103,7 @@ static void __init handle_initrd(void)
mount_root();

printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
error = ksys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
error = do_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
if (!error)
printk("okay\n");
else {
Expand Down

0 comments on commit d4440aa

Please sign in to comment.