mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 09:28:13 +00:00
Kernel+LibCore+LibC: Implement support for forcing unveil on exec
To accomplish this, we add another VeilState which is called LockedInherited. The idea is to apply exec unveil data, similar to execpromises of the pledge syscall, on the current exec'ed program during the execve sequence. When applying the forced unveil data, the veil state is set to be locked but the special state of LockedInherited ensures that if the new program tries to unveil paths, the request will silently be ignored, so the program will continue running without receiving an error, but is still can only use the paths that were unveiled before the exec syscall. This in turn, allows us to use the unveil syscall with a special utility to sandbox other userland programs in terms of what is visible to them on the filesystem, and is usable on both programs that use or don't use the unveil syscall in their code.
This commit is contained in:
parent
35efdb17f9
commit
718ae68621
11 changed files with 161 additions and 48 deletions
|
@ -84,6 +84,7 @@ enum class VeilState {
|
|||
None,
|
||||
Dropped,
|
||||
Locked,
|
||||
LockedInherited,
|
||||
};
|
||||
|
||||
static constexpr FlatPtr futex_key_private_flag = 0b1;
|
||||
|
@ -523,6 +524,9 @@ public:
|
|||
auto& unveil_data() { return m_unveil_data; }
|
||||
auto const& unveil_data() const { return m_unveil_data; }
|
||||
|
||||
auto& exec_unveil_data() { return m_exec_unveil_data; }
|
||||
auto const& exec_unveil_data() const { return m_exec_unveil_data; }
|
||||
|
||||
bool wait_for_tracer_at_next_execve() const
|
||||
{
|
||||
return m_wait_for_tracer_at_next_execve;
|
||||
|
@ -584,7 +588,7 @@ private:
|
|||
bool add_thread(Thread&);
|
||||
bool remove_thread(Thread&);
|
||||
|
||||
Process(NonnullOwnPtr<KString> name, NonnullRefPtr<Credentials>, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> current_directory, RefPtr<Custody> executable, TTY* tty, UnveilNode unveil_tree);
|
||||
Process(NonnullOwnPtr<KString> name, NonnullRefPtr<Credentials>, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> current_directory, RefPtr<Custody> executable, TTY* tty, UnveilNode unveil_tree, UnveilNode exec_unveil_tree);
|
||||
static ErrorOr<NonnullLockRefPtr<Process>> try_create(LockRefPtr<Thread>& first_thread, NonnullOwnPtr<KString> name, UserID, GroupID, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> current_directory = nullptr, RefPtr<Custody> executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
|
||||
ErrorOr<void> attach_resources(NonnullOwnPtr<Memory::AddressSpace>&&, LockRefPtr<Thread>& first_thread, Process* fork_parent);
|
||||
static ProcessID allocate_pid();
|
||||
|
@ -878,6 +882,7 @@ private:
|
|||
LockRefPtr<Timer> m_alarm_timer;
|
||||
|
||||
SpinlockProtected<UnveilData> m_unveil_data;
|
||||
SpinlockProtected<UnveilData> m_exec_unveil_data;
|
||||
|
||||
OwnPtr<PerformanceEventBuffer> m_perf_event_buffer;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue