Agent 00 – permission to kill

In Ian Fleming's books, James Bond is a double-oh agent (007): a secret agent with permission to kill!

Well, like Bond, we too can kill; um, a process, of course, that is, send it a signal. It's nowhere as dramatic and exciting as Bond, but, hey, we can! Well, IFF (if and only if) we have the permission to do so.

The required permission: the sending process must either:

  • Have root privileges—Under the modern capabilities model (recall Chapter 8, Process Capabilities), the requirement becomes that a process has the CAP_KILL capability bit set; from the man page on capabilities(7): CAP_KILL : Bypass permission checks for sending signals (see kill(2)). 
  • Own the target process, which implies that the sender's EUID (effective UID) or RUID (real UID) and the target's EUID or RUID, respectively, should match.

The man page on kill(2) specifies in more detail some corner cases on Linux regarding permissions to send signals; take a look if interested.

So, tempting as it sounds, just performing a loop like (pseudo-code follows) will not necessarily work for all processes alive, mostly because of a lack of permissions of course:

for i from 1 to PID_MAX
kill(i, SIGKILL)

Even if you were to run code such as the one shown previously as root, the system will disallow abruptly terminating key processes such as systemd (or init). (Why not try it—it's a suggested exercise anyway. Of course, trying stuff like this is asking for trouble; we suggest you try this a test VM.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.43.212