From 11dcf9cb5cf4f7f15799dedc9cdeab3cae0de64e Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 1 Aug 2016 11:52:30 +0200 Subject: [PATCH] Open process with PROCESS_QUERY_INFORMATION to fetch maps Commit ba58e5f lowered permission requirements when opening threads and processes to {PROCESS,THREAD}_QUERY_LIMITED_INFORMATION. However, when creating the /proc//maps file, the call to VirtualQueryEx requires PROCESS_QUERY_INFORMATION access Note: It seems PROCESS_QUERY_LIMITED_INFORMATION is sufficient starting with Windows 8.1, but this is neither documented on MSDN, nor is it a safe bet. It may have to do with a fixed implementation of the UAC trust levels. Let's better follow the docs for now. Signed-off-by: Corinna Vinschen --- winsup/cygwin/fhandler_process.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index eb2bf8a3e..02f7ca042 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -796,7 +796,7 @@ static off_t format_process_maps (void *data, char *&destbuf) { _pinfo *p = (_pinfo *) data; - HANDLE proc = OpenProcess (PROCESS_QUERY_LIMITED_INFORMATION + HANDLE proc = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, p->dwProcessId); if (!proc) return 0; @@ -1438,7 +1438,7 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss, PMEMORY_WORKING_SET_LIST p; SIZE_T n = 0x4000, length; - /* This appears to work despite MSDN claiming that QueryWorkingSSet requires + /* This appears to work despite MSDN claiming that QueryWorkingSet requires PROCESS_QUERY_INFORMATION *and* PROCESS_VM_READ. Since we're trying to do everything with least perms, we stick to PROCESS_QUERY_INFORMATION only unless this changes in Windows for some reason. */