Zeke-OS / zeke

A POSIX-like OS for ARM processors.
Other
88 stars 9 forks source link

More auxv data #179

Open OlliV opened 4 years ago

OlliV commented 4 years ago

I had this idea already earlier but I think I was hesitant to implement it because a stack overflow would overwrite the data. However, other OSes don't care neither.

Currently there is a userland function called mach_get_tls_addr() that can get the address of the TLS data structure, in other Unix-like OSes commonly known as auxv or auxiliary vector. Currently the TLS struct only stores errno and thread_id.

Another way we already pass this sort of data to the user space is by using thread arguments that are then read by crt1. Such information is argc, argv, and envp. The thread scheduler supports 4 arguments and the fourth argument is still unused, that could be used for passing some data that is common to all threads of the same process.

User Space Elf Loader

Linux uses auxv to pass data to the dynamic linker. Currently Zeke does the whole elf loading thing in kernel space but if there was a vdso (#178) we could possibly have an elf loader available there and move the whole thing into user space. This would require some mangling with mmap() and such but it would make loading elfs way safer as an invalid elf could only crash the user space.

However, moving the elf loader to user space would mean that loadable kernel modules will never happen. Perhaps it isn't a bad thing tho.

https://lwn.net/Articles/519085/