Can overlap segments achieve protection?
Posted: Fri Feb 06, 2015 3:28 am
Hi,
From all the information I learn segments can be used for protection. Codes in segments with different protection level usually can not access each other without using gates. But from an OS (not any famous one, it is on a book written in Chinese, mimicking Minix) I've studied, I can directly call subroutines in kernel running on level 0 from processes running on level 1.
In the OS, the kernel is running on level 0 and some system processes run on level 1. The processes are compiled with the kernel into a single image. There is no paging only segmentation. The kernel uses segments defined in GDT and every process has its own LDT. The two segments the kernel uses, one for code and one for data, code segment is not conforming, both ranging from 0 to 4GB. And the processes, use the same segments except they are defined in LDT and the protection level is 1. Thus, from my understanding, all the kernel and processes can access the whole physical memory. So the processes can access code and data in the kernel not using system calls, producing no GPF.
Is my understanding right?
And the Intel manual says:
From all the information I learn segments can be used for protection. Codes in segments with different protection level usually can not access each other without using gates. But from an OS (not any famous one, it is on a book written in Chinese, mimicking Minix) I've studied, I can directly call subroutines in kernel running on level 0 from processes running on level 1.
In the OS, the kernel is running on level 0 and some system processes run on level 1. The processes are compiled with the kernel into a single image. There is no paging only segmentation. The kernel uses segments defined in GDT and every process has its own LDT. The two segments the kernel uses, one for code and one for data, code segment is not conforming, both ranging from 0 to 4GB. And the processes, use the same segments except they are defined in LDT and the protection level is 1. Thus, from my understanding, all the kernel and processes can access the whole physical memory. So the processes can access code and data in the kernel not using system calls, producing no GPF.
Is my understanding right?
And the Intel manual says:
It seems overlap segments can be used to protect one level from another. Or it is the paging that functions. If it is the paging the functions, what is the reason to use the overlap segments, providing independent virtual memory?More complexity can be added to this protected flat model to provide more protection. For example, for the paging mechanism to provide isolation between user and supervisor code and data, four segments need to be defined: code and data segments at privilege level 3 for the user, and code and data segments at privilege level 0 for the supervisor. Usually these segments all overlay each other and start at address 0 in the linear address space. This flat segmentation model along with a simple paging structure can protect the operating system from applications, and by adding a separate paging structure for each task or process, it can also protect applications from each other. Similar designs are used by several popular multitasking operating systems.