Protecting the OS
Protecting the OS
I'm writing a 64 bits operating system. The memory model is flat with paging. I'd like to know what techniques and methods members of the community use to protect System-Level Applications from each other, since these applications will be running at privilege level 0. I would like my OS to run applications at level 0, and at the same time protect the OS from those applications.
Re: Protecting the OS
You can't.d2alphame wrote:I would like my OS to run applications at level 0, and at the same time protect the OS from those applications.
Learn to read.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Protecting the OS
Of course you can. You just need to isolate the processes in software in the same way managed language implementations protect against illegal memory accesses.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Protecting the OS
Hi,
The alternative is to minimise the amount of code that runs at CPL=0, and therefore minimise the amount of code that needs to be trusted. This is the basic idea of micro-kernels; where only a small kernel runs at CPL=0 and everything else (device drivers, etc) run at CPL=3. In general this costs a little performance (due to extra overhead in the communication between separate pieces of software), and (unless you're able to use IOMMUs to prevent drivers that use DMA or bus mastering from bypassing security) may not prevent 100% of all possible problems; but the overhead can be very low and there can be other benefits (flexibility, fault tolerance, scalability).
Cheers,
Brendan
Any software that's running at CPL=0 has access to everything; and any application running at CPL=0 has access to everything the kernel itself has access to. There are only about 4 ways to try to prevent these applications from doing anything they like (including trashing the kernel, messing with MSRs, reconfiguring the chipset, disabling long mode/paging, etc):d2alphame wrote:I'm writing a 64 bits operating system. The memory model is flat with paging. I'd like to know what techniques and methods members of the community use to protect System-Level Applications from each other, since these applications will be running at privilege level 0. I would like my OS to run applications at level 0, and at the same time protect the OS from those applications.
- Use a special language and toolchain that doesn't allow unsafe code to be created (e.g. managed code)
- run the kernel as a hyper-visor (using hardware virtualisation to protect the host from the guest/s)
- make sure all code running at CPL=0 has no bugs and is open source, and have protected/secure software distribution (to prevent "man in the middle" malicious code)
- make sure all code running at CPL=0 has no bugs and have some system to ensure only verified software can be run (e.g. require digital certificates)
The alternative is to minimise the amount of code that runs at CPL=0, and therefore minimise the amount of code that needs to be trusted. This is the basic idea of micro-kernels; where only a small kernel runs at CPL=0 and everything else (device drivers, etc) run at CPL=3. In general this costs a little performance (due to extra overhead in the communication between separate pieces of software), and (unless you're able to use IOMMUs to prevent drivers that use DMA or bus mastering from bypassing security) may not prevent 100% of all possible problems; but the overhead can be very low and there can be other benefits (flexibility, fault tolerance, scalability).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Protecting the OS
Thanks @Brendan siiiigghh... I should have been the one to design the x64 system!
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Protecting the OS
Actually, you can formally verify your compiler implementation. For instance, check out CompCert and the related Verified Software Toolchain.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Protecting the OS
If you want protection between code running at CPL=0 you need to use 32-bit protected mode with segmentation (or legacy mode within long mode). Long mode has no such feature.
Re: Protecting the OS
It does not protect the system from malicious code. However, it can protect the system from bugs.rdos wrote:If you want protection between code running at CPL=0 you need to use 32-bit protected mode with segmentation
Re: Protecting the OS
"Running at level 0" means "has full control of the computer" - so what you're asking is for applications to have full control of the computer, but be protected from each other, which is a contradiction in terms.d2alphame wrote:I would like my OS to run applications at level 0, and at the same time protect the OS from those applications.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Protecting the OS
No, it isn't. Read the thread.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Protecting the OS
Which bit isn't? The "has full control of the computer", or "is a contradiction in terms", or something in my understanding of the question?Love4Boobies wrote:No, it isn't. Read the thread.
(Though thinking again, I do realise my answer was pointless, as Brendan's answer is a much more nuanced version of what I was intending to mean.)
Re: Protecting the OS
Ok, so I'm thinking actually apps running at CPL 0 CANNOT actually be protected from each other. But I could provide some level of protection for the OS by placing it's code and data in a page that is executable + read but cannot be written to (write-protected). I think this at least puts a small sort of caution in place for unintentional interference with the OS by apps running at CPL 0.
Re: Protecting the OS
You do realise that this protection attribute can be changed at any time by any other code also running in ring0?d2alphame wrote:some level of protection for the OS by placing it's code and data in a page that is executable + read but cannot be written to (write-protected). I think this at least puts a small sort of caution in place for unintentional interference with the OS by apps running at CPL 0.
It could protect from unintended modification, but that's only small part of the whole protection.
Learn to read.
Re: Protecting the OS
Yes of course. And that's why I first pointed out that ...apps running at CPL 0 CANNOT actually be protected from each otherdozniak wrote:You do realise that this protection attribute can be changed at any time by any other code also running in ring0?
Yes I realize that. But what can I do?dozniak wrote:It could protect from unintended modification, but that's only small part of the whole protection.
Re: Protecting the OS
Combine it with requiring all CPL=0 code being contained in a signed binary, and that can be solved as well. Of course, that precludes loading drivers dynamically from disc, but if you want security you cannot allow such things anyway.Antti wrote:It does not protect the system from malicious code. However, it can protect the system from bugs.rdos wrote:If you want protection between code running at CPL=0 you need to use 32-bit protected mode with segmentation