From e2ffc7fd31f116bc13dff33829de83525f346fcd Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 10 Mar 2025 22:34:17 -0400 Subject: [PATCH] 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. --- src/system/kernel/vm/vm.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 20697af840..fb0ea399a5 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -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)