diff options
author | Linus Groh <mail@linusgroh.de> | 2021-01-28 23:46:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-29 08:45:56 +0100 |
commit | b7b09470ca7f08f42b0f3a6701192adbdf198870 (patch) | |
tree | 76850a3f61492bd2b84ca95275d7cd55407ba38b /Kernel | |
parent | 6876b9a51497956de86a29ccc5f108b1d37e4327 (diff) | |
download | serenity-b7b09470ca7f08f42b0f3a6701192adbdf198870.zip |
Kernel: Return -ENOTDIR for non-directory mount target
The absence of this check allowed silly things like this:
# touch file
# mount /dev/hda file
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Syscalls/mount.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Kernel/Syscalls/mount.cpp b/Kernel/Syscalls/mount.cpp index a212e1ef4a..5376563530 100644 --- a/Kernel/Syscalls/mount.cpp +++ b/Kernel/Syscalls/mount.cpp @@ -67,6 +67,9 @@ int Process::sys$mount(Userspace<const Syscall::SC_mount_params*> user_params) auto& target_custody = custody_or_error.value(); + if (!target_custody->inode().is_directory()) + return -ENOTDIR; + if (params.flags & MS_REMOUNT) { // We're not creating a new mount, we're updating an existing one! return VFS::the().remount(target_custody, params.flags & ~MS_REMOUNT); |