Bender
Bender

Reputation: 129

Copying and executing a syscall in a C program

I know my question might sound strange, however I am wondering what would happen if I tried to copy the source code of a syscall in a C file and if I tried to run it.

Which security mechanism of the operating system will stop the code execution?

Upvotes: 1

Views: 70

Answers (1)

It wouldn't work at all. The security mechanism that would stop it belongs to the CPU, not to the operating system. CPUs have different privilege levels that code runs at, and your userspace code would run at the lowest privilege level, which isn't allowed to do the things that kernels need to do, so the processor would fault when you tried to do them anyway.

Upvotes: 1

Related Questions