zpoline integration for an option to hijack library#524
Merged
thehajime merged 5 commits intolkl:masterfrom Aug 1, 2023
Merged
zpoline integration for an option to hijack library#524thehajime merged 5 commits intolkl:masterfrom
thehajime merged 5 commits intolkl:masterfrom
Conversation
046f0e0 to
e6e1430
Compare
thehajime
commented
Jun 27, 2023
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>
Member
Author
|
sorry to be late. the patchset is ready for review and please take a look at it. thanks ! |
AkihiroSuda
reviewed
Jul 26, 2023
Documentation/lkl.txt
Outdated
|
|
||
| - Build | ||
| ``` | ||
| make -C tools/lkl -j8 zpoine=../zpoline |
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>
Member
Author
|
thanks @AkihiroSuda @tavip for the review ! (Cc: @yasukata) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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