Skip to content
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

Closed
wants to merge 13 commits into from
Closed

fix(ffi): Fix FFI usage on distros using SELinux #15307

wants to merge 13 commits into from

Conversation

ThalusA
Copy link

@ThalusA ThalusA commented Jul 25, 2022

This is related to issue #15306

@CLAassistant
Copy link

CLAassistant commented Jul 25, 2022

CLA assistant check
All committers have signed the CLA.

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 =
Copy link
Collaborator

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?

Copy link
Author

@ThalusA ThalusA Jul 25, 2022

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

@ThalusA
Copy link
Author

ThalusA commented Jul 26, 2022

I'm using OnceCell because it will soon be integrated inside the rust standard library

Copy link
Collaborator

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

ext/ffi/lib.rs Outdated
@@ -766,6 768,24 @@ fn is_fast_api_rv(rv: NativeType) -> bool {
)
}

#[cfg(target_os = "linux")]
Copy link
Member

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

Copy link
Collaborator

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmap

Copy link
Collaborator

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!

Copy link
Member

@littledivy littledivy left a 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
Comment on lines 804 to 807
#[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;
Copy link
Member

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...

Copy link
Author

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 ?

@ThalusA
Copy link
Author

ThalusA commented Jul 29, 2022

image

Will look into that once I have time

ext/ffi/lib.rs Outdated Show resolved Hide resolved
@ThalusA
Copy link
Author

ThalusA commented Jul 29, 2022

It seems not to be as easy as we want it to be, we might either use back libloading or wait for #15305

@ThalusA
Copy link
Author

ThalusA commented Jul 31, 2022

Since this PR: #15305 would make this problem inexistent with the removal of TinyCC I will close this PR and support the other one.

@ThalusA ThalusA closed this Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants