Hi,
Crazed123 wrote:What kind of security and protection systems is everyone using? I ask because I'm extremely confused about them right now and could use some clarity on the subject.
For me the IPC mechanism is the basis for security, but the IPC mechanism doesn't have any pre-defined type of protection.
Each thread has a "thread ID", and this thread ID is always sent with every message to the receiver. The receiver is responsible for implementing any protection that is suitable for it's specific case.
Once the receiver has the thread ID it can ask the kernel which process the thread belongs to, which executable file the thread belongs to and/or which user it belongs to.
There's 2 system level processes that are considered part of the OS itself - the Virtual File System and the Device Manager. The kernel keeps track these processes from boot. All other processes are started by one of these system level processes, and all processes/threads are responsible for keeping track of who they trust (and how much).
For an example, during boot the Device Manager might find a USB controller. The Device Manager starts a USB controller device driver and remembers who it is. The USB controller device driver might see what's connected to it and start a flash memory device driver. Now the Device Manager trusts the USB driver and the USB driver trusts the flash memory driver, but the Device Manager doesn't trust the flash memory driver.
The flash memory driver might send a "connect me to the VFS" message back to the USB controller driver (who checks if it trusts the sender), and the USB controller driver sends a "connect thread X to the VFS" message back to the Device Manager (who checks if it trusts the sender). Then the Device Manager sends a "connect to thread X" message to the VFS and the VFS checks if the message came from the Device Manager. After this the VFS sends a "Hello" message to the flash memory driver (who checks if the message came from the VFS). After this the flash memory driver and the VFS driver know they can trust each other.
Of course the VFS would only trust the flash memory driver enough for it to work. For example the VFS would trust the flash memory driver as a storage device (e.g. allow it to be mounted by a file system) but wouldn't trust the flash memory driver to access "/home/me/my_personal_secrets.txt".
There is one special type of process that the Device Manager can start. It's called a "User Interface" process, and is used as an interface between GUIs/applications and certain device drivers (video, sound, keyboard, mouse, etc). When the Device Manager starts a User Interface it tells the kernel to remember that the new process is a User Interface. Once a User Interface process has been connected to video card/s, etc (by the Device Manager) it displays a login prompt.
Every process has an "Executable ID" from the file permissions (in the file system), and a "User ID" (inherited from who-ever started the process).
When a user logs in the User Interface sends a "set my User ID" message to the VFS, and the VFS checks the login details and asks the kernel to set the User Interface process' User ID if the details are valid. If the kernel wasn't told the process is a User Interface (by the Device Manager) then then kernel refuses to set the User Interface's User ID.
After a user logs in to a User Interface successfully the User Interface will read an "init" file in the user's home directory, and start processes indicated by this init file (e.g. GUIs, CLIs or any other full screen applications) - one for each virtual screen. These new processes (and any more processes they start) will inherit the same User ID as the User Interface.
For file permissions, any thread can ask the VFS to do file I/O operations and the VFS can check which process the thread belongs to from the IPC system, find out the Executable ID and User ID from this and then check if the thread has permission from this.
All files belong to an executable or a user (but never both). This means that (for e.g.) the Device Manager can't access a user's files even though it's one of the most trusted executables in the OS, and any application can create files that no user can access (although administrators can delete them).
Of course there will also be group permissions, so that (for e.g.) a file can be read by any user or executable in the "HTML" group and written to by any user or executable in the "web development" group. This is mostly the same as standard *nix file permissions (except that executables have their own Executable ID and administrators aren't given full access).
BTW for file system security there's a major compromise between flexibility/complexity and usability. As an example, for an exercise in a course I'm doing I had to setup a Windows 2000 server with file sharing (with different users and groups of users given different access to different shared resources). I found the file permission system in Windows 2000 to be much more flexible than the standard Unix system, but I also found it to be a severe pain in the neck - the extra flexibility/complexity caused more hassles than it was worth.
From my perspective you can have an extremely flexible file permission system, but most system adminstrators won't fully understand it and will leave security holes. A simpler (less flexible) file permission system is much easier to understand, much less likely to be mis-used, and therefore more likely to be secure in practice.
Cheers,
Brendan