-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
fix(ffi): Fix FFI usage on distros using SELinux #15307
Conversation
ext/ffi/lib.rs
Outdated
@@ -780,8 779,16 @@ fn make_sync_fn<'s>( | |||
|
|||
#[cfg(not(target_os = "windows"))] | |||
let mut fast_allocations: Option<*mut ()> = None; | |||
|
|||
#[cfg(target_os = "linux")] | |||
let selinux_is_enabled = |
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.
Presumably this could also be outside the function call entirely?
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.
You want me to use thread_local! or lazy_static ?
Edit: Now using once_cell
Put back the little space between `mod` and `use`
I'm using OnceCell because it will soon be integrated inside the rust standard library |
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
Co-authored-by: Aapo Alasuutari <[email protected]>
ext/ffi/lib.rs
Outdated
@@ -766,6 768,24 @@ fn is_fast_api_rv(rv: NativeType) -> bool { | |||
) | |||
} | |||
|
|||
#[cfg(target_os = "linux")] |
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.
Let's add a todo comment: // TODO(@littledivy): Don't use normal heap with mprotect PROT_EXEC for executable code to support SELinux.
to somehow make this optimization work in the future
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.
What sort of way would there be to make this work without normal heap mprotect?
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.
mmap
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.
Ah, okay. In that case the dynasmrt
will then handle this as it uses mmap. Nice!
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! Thank you
ext/ffi/lib.rs
Outdated
#[cfg(target_os = "linux")] | ||
let fastapi_is_available = *is_fastapi_available(); | ||
#[cfg(all(not(target_os = "linux"), not(target_os = "windows")))] | ||
let fastapi_is_available = true; |
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.
It would be better if these conditional compilations were inside the is_fastapi_available()
rather than conditionally defining this function...
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.
I changed it, do you like it better that way ?
# Conflicts: # ext/ffi/lib.rs
It seems not to be as easy as we want it to be, we might either use back libloading or wait for #15305 |
Since this PR: #15305 would make this problem inexistent with the removal of TinyCC I will close this PR and support the other one. |
This is related to issue #15306