Skip to content

Conversation

@devnexen
Copy link
Contributor

No description provided.

@devnexen devnexen force-pushed the netbsd_prot_mprotect branch 2 times, most recently from 8b86f80 to 1baecee Compare October 14, 2023 20:05
@devnexen devnexen marked this pull request as ready for review October 14, 2023 20:05
prot.PROT_MPROTECT(ProtFlags::PROT_READ);

unsafe {
let ptr = mmap::<BorrowedFd>(
Copy link
Member

Choose a reason for hiding this comment

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

Anonymous mapping has been remvoed from the mmap(2) interface, please use mmap_anonymous() instead

@devnexen devnexen force-pushed the netbsd_prot_mprotect branch 2 times, most recently from 303c9d2 to 90f9f18 Compare November 7, 2023 06:45
@SteveLauC
Copy link
Member

Could you please explain what this is and how it can be properly used to me?

As a NetBSD extension, the PROT_MPROTECT macro can be used to request additional permissions for later use with mprotect(2). For example PROT_MPROTECT(PROT_READ) requests that future PROT_READ mappings are allowed and can be enabled using mprotect(2), but does not currently grant read mappings to the returned memory segment.

After reading the related manual pages and the test code provided in this PR, I am still confused about the functionality of this macro.

Per the mprotect(2) manual:

EACCESS: The new protection is less restrictive than the protection originally set with mmap(2).

You will get an EACCESS error if you reset the permission that is less restrictive than the original one given in the mmap(2) call on NetBSD, does this macro solve that error and thus allow additional permissions to be added?

@devnexen devnexen force-pushed the netbsd_prot_mprotect branch from 90f9f18 to 09c7d93 Compare November 7, 2023 07:20
@devnexen
Copy link
Contributor Author

devnexen commented Nov 7, 2023

Could you please explain what this is and how it can be properly used to me?

As a NetBSD extension, the PROT_MPROTECT macro can be used to request additional permissions for later use with mprotect(2). For example PROT_MPROTECT(PROT_READ) requests that future PROT_READ mappings are allowed and can be enabled using mprotect(2), but does not currently grant read mappings to the returned memory segment.

After reading the related manual pages and the test code provided in this PR, I am still confused about the functionality of this macro.

Per the mprotect(2) manual:

EACCESS: The new protection is less restrictive than the protection originally set with mmap(2).

You will get an EACCESS error if you reset the permission that is less restrictive than the original one given in the mmap(2) call on NetBSD, does this macro solve that error and thus allow additional permissions to be added?

This macro is for mprotect so let 's say you do this for mmap with this flag PROT_READ | PROT_WRITE | PROT_MPROTECT(PROT_EXEC) the actual page won t have PROT_EXEC flag allowed until mprotect request it, if that makes sense

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