kernel/vm: Don't report kernel protection to userland except for root.

And don't report other UIDs' area informations at all.

Fixes a TODO.
This commit is contained in:
Augustin Cavalier
2025-03-10 22:34:17 -04:00
parent e87593ae21
commit e2ffc7fd31
+16 -3
View File
@@ -6050,8 +6050,14 @@ _user_get_area_info(area_id area, area_info* userInfo)
if (status < B_OK)
return status;
// TODO: do we want to prevent userland from seeing kernel protections?
//info.protection &= B_USER_PROTECTION;
if (geteuid() != 0) {
if (info.team != team_get_current_team_id()) {
if (team_geteuid(info.team) != geteuid())
return B_NOT_ALLOWED;
}
info.protection &= B_USER_AREA_FLAGS;
}
if (user_memcpy(userInfo, &info, sizeof(area_info)) < B_OK)
return B_BAD_ADDRESS;
@@ -6076,7 +6082,14 @@ _user_get_next_area_info(team_id team, ssize_t* userCookie, area_info* userInfo)
if (status != B_OK)
return status;
//info.protection &= B_USER_PROTECTION;
if (geteuid() != 0) {
if (info.team != team_get_current_team_id()) {
if (team_geteuid(info.team) != geteuid())
return B_NOT_ALLOWED;
}
info.protection &= B_USER_AREA_FLAGS;
}
if (user_memcpy(userCookie, &cookie, sizeof(ssize_t)) < B_OK
|| user_memcpy(userInfo, &info, sizeof(area_info)) < B_OK)