mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 12:25:07 +00:00

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.
36 lines
1 KiB
C++
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;
|
|
};
|
|
|
|
}
|