mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
Kernel: Store TTY's foreground process as a WeakPtr<Process>
This ensures that we don't leave a stale PGID assigned to the TTY after the process exits, which would make PID recycling attacks possible.
This commit is contained in:
parent
ff01cfa08a
commit
ddab7ab693
3 changed files with 22 additions and 12 deletions
|
@ -27,14 +27,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/CircularDeque.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <Kernel/Devices/CharacterDevice.h>
|
||||
#include <Kernel/DoubleBuffer.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class Process;
|
||||
|
||||
class TTY : public CharacterDevice {
|
||||
public:
|
||||
virtual ~TTY() override;
|
||||
|
@ -51,8 +50,7 @@ public:
|
|||
unsigned short rows() const { return m_rows; }
|
||||
unsigned short columns() const { return m_columns; }
|
||||
|
||||
void set_pgid(pid_t pgid) { m_pgid = pgid; }
|
||||
pid_t pgid() const { return m_pgid; }
|
||||
pid_t pgid() const;
|
||||
|
||||
void set_termios(const termios&);
|
||||
bool should_generate_signals() const { return m_termios.c_lflag & ISIG; }
|
||||
|
@ -93,7 +91,7 @@ private:
|
|||
virtual bool is_tty() const final override { return true; }
|
||||
|
||||
CircularDeque<u8, 1024> m_input_buffer;
|
||||
pid_t m_pgid { 0 };
|
||||
WeakPtr<Process> m_process;
|
||||
termios m_termios;
|
||||
unsigned short m_rows { 0 };
|
||||
unsigned short m_columns { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue