To ask questions about priviledge change

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
leetow2003
Member
Member
Posts: 70
Joined: Fri Nov 19, 2010 6:54 pm

To ask questions about priviledge change

Post by leetow2003 »

The first I use instruction RETF from 0 ring to 3 ring,then I use calling gate
from ring 3 to ring 0,I want to know:
(1) These code segments are 32-bit segments,
so the stack segments must be 32-bit segmnet,is my opinion right?
(2) The DPL of calling gate is 3,its RPL must be 3,
is my opinion right?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: To ask questions about priviledge change

Post by egos »

leetow2003 wrote:(1) These code segments are 32-bit segments, so the stack segments must be 32-bit segmnet,is my opinion right?
Yes. And esp value should be multiple of 4 bytes.
leetow2003 wrote:(2) The DPL of calling gate is 3,its RPL must be 3, is my opinion right?
No. Here the same rule applies as for data access: Max(CPL, RPL) <= DPL (usually CPL=RPL). I.e. you can use same gate to transfer control to the kernel from any privilege level if its DPL=3.
If you have seen bad English in my words, tell me what's wrong, please.
rdos
Member
Member
Posts: 3310
Joined: Wed Oct 01, 2008 1:55 pm

Re: To ask questions about priviledge change

Post by rdos »

egos wrote:
leetow2003 wrote:(1) These code segments are 32-bit segments, so the stack segments must be 32-bit segmnet,is my opinion right?
Yes. And esp value should be multiple of 4 bytes.
No. A 32-bit application can have a 16-bit kernel stack (for instance). The bitness of the stack segment only determines if the processor uses SP or ESP.

A segmented, 32-bit, application could also theoretically have a 16-bit stack segment. The code would not be dependent on this. Size for pushes are determined by code segment bitness, not stack segment bitness.
Post Reply