-
mark@chromium.org authored
commit 919148f94db54fc04d287eb6a42c0c36b166bbfa Merge: e2ca3c3 84a5bd9 Author: Jonathan 'Wolf' Rentzsch <jwr.git@redshed.net> Date: Sun May 11 21:51:20 2014 -0500 Merge pull request #16 from mark-chromium/patch-1 [FIX] Stop using mach_host_self and host_page_size, fixing a port right leak. (Mark Mentovai) commit 84a5bd929213b9e0f059d3bc8c5b738e9fe4e620 Author: Mark Mentovai <mark@chromium.org> Date: Fri May 9 16:40:10 2014 -0400 Stop using mach_host_self and host_page_size, fixing a port right leak It is incorrect to use mach_host_self without disposing of the send send right to the host port with mach_port_deallocate when done with it. http://crbug.com/105513 shows the sorts of problems that can arise when send rights aren’t properly deallocated. mach_host_self was only used by mach_override to be able to call host_page_size. host_page_size is unnecessary, because it always returns a constant value, PAGE_SIZE, which is also known at user-land compile time. See libsyscall/mach/mach_init.c. User code is better off just using this macro directly, and not fumbling with the system calls to obtain and properly dispose of a send right to the host port. (You need to mach_port_deallocate the ports you get from mach_host_self and mach_thread_self, but you must not normally deallocate the one from mach_task_self, because mach_task_self is actually just a macro that references a global variable. It doesn’t add any port rights at all. See <mach/mach_init.h>. If you bypass the macro and call the real mach_task_self system call, you do need to call mach_port_deallocate, but this situation is incredibly rare.) R=rsesek@chromium.org Review URL: https://codereview.chromium.org/282523004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269785 0039d316-1c4b-4281-b951-d872f2087c98
32fcda1f