Skip to content

Generate 64-bit and 32-bit bindings#111

Merged
l0kod merged 1 commit intolandlock-lsm:mainfrom
l0kod:32b
Oct 21, 2025
Merged

Generate 64-bit and 32-bit bindings#111
l0kod merged 1 commit intolandlock-lsm:mainfrom
l0kod:32b

Conversation

@l0kod
Copy link
Member

@l0kod l0kod commented Oct 2, 2025

See #110

@bjorn3
Copy link
Contributor

bjorn3 commented Oct 2, 2025

Wouldn't this break all non x86/x86_64 archs?

@l0kod
Copy link
Member Author

l0kod commented Oct 3, 2025

Wouldn't this break all non x86/x86_64 archs?

Yes, but it gives guarantee that we tested with these archs. I was also thinking about adding two generic 32-bit and 64-bit bindings without tests, but I'm not sure if that would be correct for most/all other archs.

@l0kod
Copy link
Member Author

l0kod commented Oct 15, 2025

I tested with ARM 32-bit and 64-bit (which always have 8-bytes alignment) and the new landlock_all.rs should work fine. With the latest changes, this crate will be supported by all architectures. Please let me know of any potential issue.

Cc @alexanderkjall

Until now, we only used the x86_64 architecture, but here are the
changes to use this crate on any architecture.

Add the bindgen.sh script to make update simple:

  ./src/uapi/bindgen.sh .../linux-6.12

This call creates three binding files:
- landlock_x86_64.rs
- landlock_i686.rs
- landlock_all.rs

Only landlock_all.rs is generated without memory layout tests to make it
architecture-agnostic.

For instance, x86_64-linux-gnu (64-bit), aarch64-unknown-linux-gnu
(64-bit), and armv7-unknown-linux-gnueabi (32-bit) all align memory on
8 bytes, which is not the case for i686-linux-gnu (32-bit).  This makes
i686 tests incompatible for bindgen_test_layout_landlock_ruleset_attr()
and bindgen_test_layout_landlock_net_port_attr().

Extend the CI to build and test on i686.

Closes: landlock-lsm#110
Signed-off-by: Mickaël Salaün <mic@digikod.net>
@l0kod l0kod mentioned this pull request Oct 21, 2025
@l0kod l0kod merged commit f79da18 into landlock-lsm:main Oct 21, 2025
19 checks passed
@l0kod l0kod deleted the 32b branch October 21, 2025 10:06
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.

2 participants