-
Notifications
You must be signed in to change notification settings - Fork 87
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
rt_sigprocmask syscall implementation #112
Conversation
Excellent! This is one of major missing features in Kerla 🎉
How about using let how = match how {
0 => SignalMask::Block,
_ => return Err(Errno::EINVAL.into());
};
current_process().rt_sigprocmask(how, set, oldset, length)
I agree we can go with 1024 bits. Let's add Regarding the bitmap stuff, I think there're some possible optimizations too. The crate you mentioned looks neat and perhaps we'll replace our bitmap implementation with it. Let's discuss this topic in a separate issue later 😃 |
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.
Could you have a look at my review?
I just checked, every time rt_sigprocmask is called during our integration tests, the And I added actual signal filtering in the last commit. Please take a look. |
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.
Generally looks good to me! Just leave some nitpicks.
It seems I was confused with the difference between Please check if the length is |
Co-authored-by: Seiya Nuta <nuta@seiya.me>
Co-authored-by: Seiya Nuta <nuta@seiya.me>
Done I will create a ticket for bitmap stuff later. And maybe I should update https://github.com/nuta/kerla/blob/main/Documentation/compatibility.md ? |
I'll update |
Thanks a lot, @Lurk! |
@nuta somehow I missed Clippy warning :( error: redundant pattern matching, consider using `is_err()`
--> kernel/syscalls/rt_sigprocmask.rs:27:16
|
27 | if let Err(_) = current_process().set_signal_mask(how, set, oldset, length) {
| -------^^^^^^-------------------------------------------------------------- help: try this: `if current_process().set_signal_mask(how, set, oldset, length).is_err()`
|
= note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` Should I open a new pull request? |
This pull request adds rt_sigprocmask syscall handler (https://man7.org/linux/man-pages/man2/sigprocmask.2.html).
Before adding signal filtering, I want to discuss the general approach.
Things that bother me:
I feel like the
how
argument should be an enum, but how to handleEINVAL
in that case?And the
length
argument doesn't make any sense to me. According to the manual, it issizeof(kernel_sigset_t)
, and according to kernel sources,kernel_sigset_t
is 1024 bits. So it always, according to POSIX, should be 128 bytes, unless we will run on something exotic like PDP-6/10 or DSP. If you can point me to some document or discussion to make sense of it, I would be grateful.Also
set
andoldset
are 1024 bits in length. I am using a slightly modified BitMap from kerla_utils, but it is suboptimal. It is [u8;128], which means we have 128 iterations onSIG_BLOCK
andSIG_UNBLOCK
. The solution can be generic over the type BitMap. Or create a new LongBitMap, which will use u128 under the hood. Or, maybe we can use or take inspiration from something like https://docs.rs/bitmaps/latest/bitmaps/. But I have a feeling that this is a task by itself, and should be discussed in a separate issue/PR.