Closed joxie closed 3 months ago
@AoteJin can you update your discussion with Penglai guys
Penglai team claim that their architecture does not requirement per privilege-mode debug control. They could accommodate current proposal by:
- Add supervisor RT layer for debug of u-mode only partition
Hi, What if CPU only implements M+U without S-mode?
Hello @AoteJin
Would you like to explain what per privilege-mode debug control
means ?
I might miss the discussion in previous TG meeting.
Hello @AoteJin Would you like to explain what
per privilege-mode debug control
means ? I might miss the discussion in previous TG meeting.
I would love to. The external debug security proposal has two level control: machine (from RoT) and submachine (by M-mode CSR).
What if CPU only implements M+U without S-mode?
In an implementation without S-mode, these two controls are enough to separately manage debuggability of M and U.
This issue is to discuss the case that an implementation has privilege levels more than M/U (e.g. M/S/U) and machine mode launches directly to U-mode. This might be a problem because submachine mode control does not differentiate S/U and results in privilege escalation in terms external debug.
What if CPU only implements M+U without S-mode?
In an implementation without S-mode, these two controls are enough to separately manage debuggability of M and U.
Yes, U-mode external debug can be managed by sdbgen
, in M+U system. Thanks!
This issue is to discuss the case that an implementation has privilege levels more than M/U (e.g. M/S/U) and machine mode launches directly to U-mode. This might be a problem because submachine mode control does not differentiate S/U and results in privilege escalation in terms external debug.
What the privilege escalation is here?
Do you mean debugger could read S-mode CSR or memory (e.g., satp, stvec) ?
Because maximum debug privilege is S-mode when mdbgen=0
and sdbgen=1
What the privilege escalation is here? Do you mean debugger could read S-mode CSR or memory (e.g., satp, stvec) ? Because maximum debug privilege is S-mode when mdbgen=0 and sdbgen=1
Yes, this is exactly the concern.
Another problem is dcsr.PRV
?
U-mode debugger can write dcsr.PRV
as S-mode (Because maximum debug privilege is S-mode) and dret to S-mode, am I correct?
Technically, there are only M-mode debugger and subM-mode debugger defined in proposal. And the subM-mode debugger can write dcsr.PRV
as S-mode then dret.
I agree it is another attack vector for privilege escalation.
Hmm.. The hart knows the previous privilege mode (i.e., U-mode) when the hart enters Debug Mode.
In external debug security spec section 3.4.1 says:
It will generate a security fault error (cmderr 6) if the external debugger attempts to configure prv and v with a privilege higher than the maximum debug privilege level.
Maybe it can changed to: It will generate a security fault error (cmderr 6) if the external debugger attempts to configure prv and v with a privilege higher than the "previous" privilege level.
I mean, when external debugger executing abstract commands to read/write CSR, memory, hart can check both maximum debug access privilege
and "previous" privilege level.
For example, dcsr.PRV
can not be configured to S-mode if previous privilege level is U-mode.
I mean, when external debugger executing abstract commands to read/write CSR, memory, hart can check both maximum debug access privilege and "previous" privilege level. For example, dcsr.PRV can not be configured to S-mode if previous privilege level is U-mode.
This is not directly related to this ticket. If you have concern on it, would better to discuss it on a separate issue. The reason not checking against previous privilege is that the subM debugger might stop on U-mode and it will need higher privilege "view" to debug the U-mode, e.g. VA->PA mapping etc. We do not want to break this use case.
subM debugger might stop on U-mode and it will need higher privilege "view" to debug the U-mode, e.g. VA->PA mapping etc. We do not want to break this use case.
@AoteJin Thank you !
Now I understand why the spec specifies maximum debug access privilege
rather than previous privilege level
.
Closing. Based on the information TG has as of today, we do not see a need to have fine grain control.
Open this ticket to track potential need for per privilege control for external debug / trace