Janichsan, on October 20th 2007, 07:32 PM, said:
Not necessarily. When you tamper around with stuff you are no supposed to tamper with, you can crash your computer spectacularily. The last kernel panic I had was caused by myself, by trying to write a multithreading program without actually knowing what I doing.
Unless you were writing a kernel extension, that was a bug in the kernel. Actually, it was even if you were: it would then just be a kernel bug that you introduced.
Quote
Believe me: every OS - even the most the modern and safe ones - can be brought down by crappy programming.
Right, every OS has bugs.
Nicholas, on October 20th 2007, 08:05 PM, said:
But the OS should protect against things like that though...
Exactly. The whole point of having separate kernel and user modes, and memory protection, is to remove the need to trust user programs. The kernel is meant to put each program in a sandbox where it can't directly affect other programs. They have to go through interfaces provided by the kernel. It's the kernel's job to make sure that the things that user programs ask it to do are safe (for some definition of "safe", which generally includes things like not corrupting memory belonging to the kernel or other programs).
So when you call read() with an invalid buffer pointer, the kernel doesn't try to write to it and cause a segfault (or worse, overwrite some random memory), it detects that it is invalid and the syscall returns EFAULT. Any syscall or sequence of syscalls should be similarly safe, such that the worst that can happen is that the calling program corrupts its own data or is terminated.