Skip to content

Conversation

@hexagonal-sun
Copy link
Owner

Implement the mprotect syscall, splitting VMAs if required, etc.

Page align any non-aligned program headers, fixing up the file offset
and filesz accordingly.
Add a function for calculating the set difference when punching one
region out of another.
Implement a `shrink_to` function for a VMA. This shrinks the VMA's
region to the specified region, while recalculating file offsets and
size if the VMA is file-backed.
@hexagonal-sun hexagonal-sun changed the title WIP: implement mprotect Implement mprotect Nov 30, 2025
Implement the `mprotect` syscall. Including a bunch of tests for
ensuring proper VMA functionality regarding splitting and merging via
`mprotect`.
@hexagonal-sun
Copy link
Owner Author

@arihant2math @BjornTheProgrammer Please feel free to do a quick review.

On my machine, this implements enough syscall for me to be able to run busybox now!

[    0.628130] drivers::interrupts::arm_gic_v3: GICv3: CPU interface for core 3 enabled.
[    0.628500] arch::arm64::boot::secondary: CPU 3 online.
[    0.632754] interrupts::cpu_messenger: CPU 1 recieved ping from CPU 0
bash-5.3# ./bin/busybox
BusyBox v1.36.0 (2023-04-24 07:00:56 UTC) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

Usage: busybox [function [arguments]...]
   or: busybox --list[-full]
   or: busybox --show SCRIPT
   or: busybox --install [-s] [DIR]
   or: function [arguments]...

🎉

Copy link
Contributor

@BjornTheProgrammer BjornTheProgrammer left a comment

Choose a reason for hiding this comment

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

No modifications were needed to get this properly working on my machine!

Copy link
Collaborator

@arihant2math arihant2math left a comment

Choose a reason for hiding this comment

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

Same here (aarch64 macos host).

@hexagonal-sun
Copy link
Owner Author

Perfect. Thanks for checking.

@hexagonal-sun hexagonal-sun merged commit 910203e into master Nov 30, 2025
1 check passed
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.

4 participants