Skip to content
Commit 570d7a98 authored by Eric Biggers's avatar Eric Biggers Committed by Al Viro
Browse files

vfs: move_mount: reject moving kernel internal mounts



sys_move_mount() crashes by dereferencing the pointer MNT_NS_INTERNAL,
a.k.a. ERR_PTR(-EINVAL), if the old mount is specified by fd for a
kernel object with an internal mount, such as a pipe or memfd.

Fix it by checking for this case and returning -EINVAL.

[AV: what we want is is_mounted(); use that instead of making the
condition even more convoluted]

Reproducer:

    #include <unistd.h>

    #define __NR_move_mount         429
    #define MOVE_MOUNT_F_EMPTY_PATH 0x00000004

    int main()
    {
    	int fds[2];

    	pipe(fds);
        syscall(__NR_move_mount, fds[0], "", -1, "/", MOVE_MOUNT_F_EMPTY_PATH);
    }

Reported-by: default avatar <syzbot+6004acbaa1893ad013f0@syzkaller.appspotmail.com>
Fixes: 2db154b3 ("vfs: syscall: Add move_mount(2) to move mounts around")
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent d728cf79
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment