-
Notifications
You must be signed in to change notification settings - Fork 708
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
Improve FFI safety w.r.t. alignment and sizing #36
Comments
Partially fixed with 377f611. The work mentioned above still needs to be done. More work on checking alignment and size of other primitive types, like pointer types, is also needed. |
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57271. On ARM we may need to align to 16 or even 32 bytes for any function that might use NEON instructions that access memory. |
See also rust-lang/rfcs#325 and rust-lang/rust#26403. Without a fix for that issue, we probably have to work around the problem by padding all our FFI context buffers with 16 or 32 extra bytes, and calculate the aligned addresses ourselves. |
C99 section 7.20.3: "The order and contiguity of storage allocated by successive calls to the calloc, malloc, and realloc functions is unspecified. The pointer returned if the allocation succeeds is suitably aligned so that it may be assigned to a pointer to any type of object and then used to access such an object or an array of such objects in the space allocated" |
The situation for |
See the checked_struct branch, particularly, cd53d14.
That is incomplete in that it doesn't address alignment from the Rust side. In particular, we assume that the alignment of
u64
is 8 bytes, but we don't assert that.It is also incomplete because it doesn't do the FFI checking for
ring::digest
.The text was updated successfully, but these errors were encountered: