kernel/vm: Allow more maximum protection for mmap'ed areas

Always allow a memory region mapped by `map_file` to change its
protection to any user protection flags other than `B_WRITE_AREA`.
This flag should only be settable when the file is opened with
write access.

Change-Id: Icc00c08fc033b3bd6b6ceb2833bf566c72914007
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6389
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: John Scipione <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Trung Nguyen
2023-05-12 16:43:48 +00:00
committed by waddlesplash
parent 44233abf11
commit bbd6beb7ee
+3 -2
View File
@@ -2055,9 +2055,10 @@ _vm_map_file(team_id team, const char* name, void** _address,
uint32 protectionMax = 0;
if (mapping != REGION_PRIVATE_MAP) {
protectionMax = protection | B_READ_AREA;
if ((openMode & O_ACCMODE) == O_RDWR)
protectionMax |= B_WRITE_AREA;
protectionMax = protection | B_USER_PROTECTION;
else
protectionMax = protection | (B_USER_PROTECTION & ~B_WRITE_AREA);
}
// get the vnode for the object, this also grabs a ref to it