Comment by samus
2 years ago
A kernel is not a programming languages. Type safety is something enforced by a compiler or interpreter, while accessing a system call interface is always something that can be expressed in terms of a sequence of assembly language instructions. Doesn't matter whether you're accessing a C API or a syscall mechanism.
Forcing usage of libc is actually an effort towards type safety. `syscall` just takes a syscall number and an unspecified amount of arguments of unconstrained type. It's the opposite of being type safe.
It does matter. You don't have to link with the kernel, or support the C ABI. You're still tied to C with libc. It's especially bad on Linux because glibc is so awful.
Forcing libc has absolutely nothing to do with type safety. How do you think they invoke syscalls in libc? There's no more type checking of syscalls there than there is in Go's standard library. From a user's point of view it's identical, except you don't have to worry about endless glibc version errors with Go.
Glibc and the situation on Linux is not involved at all here; we're talking about OpenBSD that takes invoking system calls via libc very seriously.
The libc can enforce some minimal sanity checks on the syscall arguments. For example the number of arguments and some early validation to avoid entering the kernel if failure can be foreseen. But the main utility is to make it more difficult to use Return Oriented Programming to build exploits.