In the course of learning, I found that "consistency" and "inconsistency"CodeThe definition of the section is not too clear, so I made a round online and summarized it to help me better understand it! Haha
1. The so-called "consistent code segment" aims to share. For example, if the privileged level of the consistent code segment is 2, the consistent code can be accessed even if the privileged level is 3. That is, allow low-Permission code to access high-Permission code. After successful access, the current privileged level is not the target code's privileged level, but the original code's privileged level. That is to say, CPL remains unchanged after the jump. It should be noted that the DPL definition of consistent code segments defines the highest permission to allow access to change consistent code segments, that is, if you have a higher permission than DPL in a consistent code segment, you are not allowed to access this consistent code segment.
2. For non-consistent code segments, only transfer at the same privilege level is allowed.
There are the following reasons:
(1) high-privilege Code cannot be called at the low-privilege level, that is, code at the High-privilege level is protected.
(2) Low-privilege Code cannot be called at the High-privilege level. In order to prevent low-privilege code from obtaining high-privilege level code, some system commands can be executed.
That is to say:
If the transfer target is a consistent code segment, as long as CPL> = DPL can be transferred, and CPL remains unchanged, that is, access the High-privilege code at the original privileged level, this is "consistent ".
If the transfer target is a non-consistent code segment, only CPL = DPL allows the transfer.
Summary: DPL of the same code segment specifies the highest permission for successfully accessing it. Code with a higher permission cannot access it successfully. After a consistent code segment is successfully accessed, CPL remains the original permission. Such settings are mainly for sharing, such as some function libraries, without permission restrictions.