Lecture 6 - 28 September 2023

Topics covered:

P0 Status

We received 6 initial submissions by the initial P0 deadline and assigned peer reviews.

Kernelspace vs userspace demo

We took another look at the demo we posted on L05 after class.

That demo can be found here and obtained by running:

git clone https://kdlp.underground.software/cgit/priv_rdmsr_demo

Ensure that you are comfortable with some of the introductory details we discussed in L05.

Recall from L05 that a trap is a type of CPU exception.

We browsed the source for the Linux implementation of trap handling to understand the codepath that executes when the user executes the “UD2” instruction and prints a message to the kernel ring buffer (dmesg).

Th address of the handler for this exception is defined in arch/x86/kernel/traps.c, as exc_invalid_op. Elsewhere, the corresponding row of the IDT is set to this address, so when the exception is generated, handle_invalid_op is called.

If you are interested in the IDT then may also be interested in the GDT.

Linux implements a lot of x86-specific IDT related code in arch/x86/kernel/idt.c.

Before next class

Important Reminders

Initial submission for E1 is due Tuesday 3 October 2023. We suggest that you get started early.