From 3f74e66e823f7c07f6817bb8c2288f0e4230be85 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 3 Jan 2020 04:10:05 +0100 Subject: [PATCH] Kernel: rename() should fail with EXDEV for cross-device requests POSIX does not support rename() from one file system to another. --- Kernel/FileSystem/VirtualFileSystem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 5539032e69..377bb14e93 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -396,6 +396,9 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base) auto& old_parent_inode = old_parent_custody->inode(); auto& new_parent_inode = new_parent_custody->inode(); + if (&old_parent_inode.fs() != &new_parent_inode.fs()) + return KResult(-EXDEV); + if (!new_parent_inode.metadata().may_write(current->process())) return KResult(-EACCES);