Kernel+LibC: Implement a few mount flags

We now support these mount flags:
* MS_NODEV: disallow opening any devices from this file system
* MS_NOEXEC: disallow executing any executables from this file system
* MS_NOSUID: ignore set-user-id bits on executables from this file system

The fourth flag, MS_BIND, is defined, but currently ignored.
This commit is contained in:
Sergey Bugaev 2020-01-11 18:45:38 +03:00 committed by Andreas Kling
parent 2fcbb846fb
commit 61c1106d9f
Notes: sideshowbarker 2024-07-19 10:11:43 +09:00
4 changed files with 19 additions and 5 deletions
Kernel/FileSystem

View file

@ -216,11 +216,13 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::open(StringView path, int options
should_truncate_file = options & O_TRUNC;
}
if (options & O_EXEC) {
if (!metadata.may_execute(current->process()))
if (!metadata.may_execute(current->process()) || (custody.mount_flags() & MS_NOEXEC))
return KResult(-EACCES);
}
if (metadata.is_device()) {
if (custody.mount_flags() & MS_NODEV)
return KResult(-EACCES);
auto device = Device::get_device(metadata.major_device, metadata.minor_device);
if (device == nullptr) {
return KResult(-ENODEV);