Installing Your Own Trap

A student proposes a new instruction, settrap, that any process may execute to register its own handler address for a chosen trap number. They argue it is safe because the kernel still validates the syscall number inside the handler, and because the handler address must point into the calling process's own address space.

What breaks?

A

Every process would need its own trap table, and the CPU caches only one table address, so switching processes would require flushing it on every context switch

B

A trap raises the privilege level as part of taking the trap, so the process's own code would begin running in kernel mode with full access to the machine

C

Trap handlers must be reentrant, and user code written without that discipline would corrupt kernel state when a second interrupt arrives

D

The trap table has to live in kernel memory, and a user process cannot write to those pages, so the instruction would simply fault