Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which registers are protected from user space in linux?

How can I find out which registers are protected by the Linux kernel to keep user assembly from writing to them?

like image 332
Dr.Knowitall Avatar asked Dec 01 '22 23:12

Dr.Knowitall


1 Answers

First of all, note that the Linux kernel itself doesn't really protect registers. All it does is make sure user applications run with privilege level 3 (lowest privilege). From that point, it's the processor that enforces protection of registers.

Here is a list of registers that are only accessible from privilege level 0 (i.e., from the kernel):

  • Control registers (CR0 - CR4)
  • GDTR, LDTR and IDTR (Global/Local/Interrupt Descriptor Table Register)
  • TR (Task Register)
  • Debug registers (DR0 - DR7)
  • All Model Specific Registers (MSRs)

You should read Chapter 5 of Intel's System Programming Manual for a detailed explanation on protection on the x86.

like image 129
mtvec Avatar answered Dec 11 '22 10:12

mtvec