1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 12:25:07 +00:00
serenity/Kernel/FileSystem/SysFS/Subsystems/Kernel/GlobalInformation.h
Liav A 1ca0ac5207 Kernel: Disallow jailed processes to read files in /sys/kernel directory
By default, disallow reading of values in that directory. Later on, we
will enable sparingly read access to specific files.

The idea that led to this mechanism was suggested by Jean-Baptiste
Boric (also known as boricj in GitHub), to prevent access to sensitive
information in the SysFS if someone adds a new file in the /sys/kernel
directory.
2022-12-03 05:47:58 -07:00

36 lines
1 KiB
C++

/*
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Error.h>
#include <AK/Try.h>
#include <AK/Types.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
#include <Kernel/FileSystem/SysFS/Component.h>
#include <Kernel/KBufferBuilder.h>
#include <Kernel/Library/LockRefPtr.h>
#include <Kernel/Locking/Mutex.h>
#include <Kernel/UserOrKernelBuffer.h>
namespace Kernel {
class SysFSGlobalInformation : public SysFSComponent {
public:
virtual ErrorOr<size_t> read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription* description) const override;
protected:
explicit SysFSGlobalInformation(SysFSDirectory const& parent_directory);
virtual ErrorOr<void> refresh_data(OpenFileDescription&) const override;
virtual ErrorOr<void> try_generate(KBufferBuilder&) = 0;
virtual bool is_readable_by_jailed_processes() const { return false; }
mutable Mutex m_refresh_lock;
};
}