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

Update landlock.h #62

Merged
merged 3 commits into from
Apr 2, 2024
Merged

Update landlock.h #62

merged 3 commits into from
Apr 2, 2024

Conversation

NicolasT
Copy link
Owner

@NicolasT NicolasT commented Apr 2, 2024

No description provided.

@NicolasT NicolasT added the enhancement New feature or request label Apr 2, 2024
When allocating a struct of a specific size, but only filling in some
members, everything should be zeroed out first (before, e.g., passing
the struct to the kernel).

This was not an issue until now, since the relevant API structures are
always fully filled, however, with an upcoming Landlock struct change,
this is required: when not zeroing the memory, some random values would
be passed to the kernel, resulting in an error (this could only be
reproduced on GHC 8.10 and 9.0, though, it looks like more recent
versions have `alloca` return zeroed memory).

Where before `Foreign.Marshal.Utils.with` was used to get a pointer to a
structure, `with0` is introduced which basically does the same
(`alloca`, `poke`, run the callback), but uses `fillBytes` to zero out
the `alloca`ted memory before `poke`ing the `Storable` in place.
@NicolasT NicolasT merged commit cec23a6 into main Apr 2, 2024
18 checks passed
@NicolasT NicolasT deleted the update-landlock-h branch April 2, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant