-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zpoline integration for an option to hijack library #524
Conversation
046f0e0
to
e6e1430
Compare
80a4d3a
to
ee602d8
Compare
When epoll_create of host syscall fails, it returns a negative integer, not zero. Thus the condition of if statement was wrong. This commit fixes this issue. Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
This is problematic when an application uses TLS on thread 0, and LKL is loaded via dlmopen. when lkl_syscall is called, it tries to get pthread_key but there are existing key/data, then lkl_syscall uses the existing one and it's not task_struct so, crashed. The root cause is that __pthread_keys is a global symbol and isolated via namespace created by dlmopen, while pthread_getspecific looks at the storage of the thread, which are not isolated via dlmopen. There are a discussion which I found. - pthread_key_create, pthread_setspecific are incompatible with dlmopen https://sourceware.org/bugzilla/show_bug.cgi?id=24776 A work around is to avoid using pthread_key API when LKL is loaded via dlmopen(3) and replace TLS function upon the initialization. We only fixed for posix host environment as dlmopen(3) is only usable on Linux implementation (AFAIK). Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
This commit add a testcase when LKL is loaded via dlmopen(3) function call. In this situation, the thread specific data which LKL uses behaves wrong and cause an unconditional memory access. This test should detect this case. note 230614: the test hungs at this moment on the multiple pthread_exit(), which is due to a lock handling on load of libgcc_s.so. Still investigating what's going on. If we replace dlmopen with dlopen, everything goes fine.. Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
This commit add an exception to the checkpatch.pl to silence warnings of compiler attributes styles (e.g., __unused, __alias, etc), as the userspace code used in LKL is hard to include headers from include/linux/compiler.h and tools/include/linux/compiler.h. Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
sorry to be late. the patchset is ready for review and please take a look at it. thanks ! |
Documentation/lkl.txt
Outdated
|
||
- Build | ||
``` | ||
make -C tools/lkl -j8 zpoine=../zpoline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: zpoine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, fixed.
This commit introduces an integration with zpoline (*1), which is a mechanism to rewrite binary upon loading. zpoline allows us to replace symbols of system call to different functions, which current LKL hijack library does the same thing in a different way, by using symbol replacement via LD_PRELOAD. The benefit of zpoline is that the replacement of syscall is at the instruction of `syscall` or `sysenter`, which userspace program can catch all syscalls, while the approach based on LD_PRELOAD cannot when the symbols of interet are hidden within libc (e.g., __socket). For more detail about the internal of zpoline, take a look at *1. *1: https://github.com/yasukata/zpoline Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work!
thanks @AkihiroSuda @tavip for the review ! (Cc: @yasukata) |
this is still under progress but we've been working on another implementation of hijack library. More to come soon and will publish as (non-draft) a pull request here.
https://github.com/yasukata/zpoline