bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH gnumach] ipc: warn about more port management bugs


From: Justus Winter
Subject: [PATCH gnumach] ipc: warn about more port management bugs
Date: Thu, 22 Jan 2015 22:22:05 +0100

* ipc/mach_port.c (mach_port_destroy): Simplify expression.
(mach_port_deallocate): Likewise.
(mach_port_mod_refs): Also warn about errors when using this function.
---
 ipc/mach_port.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/ipc/mach_port.c b/ipc/mach_port.c
index c7d9b81..439001e 100644
--- a/ipc/mach_port.c
+++ b/ipc/mach_port.c
@@ -570,7 +570,7 @@ mach_port_destroy(
 
        kr = ipc_right_lookup_write(space, name, &entry);
        if (kr != KERN_SUCCESS) {
-               if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space 
== current_space()) {
+               if (MACH_PORT_VALID (name) && space == current_space()) {
                        printf("task %.*s destroying an invalid port %lu, most 
probably a bug.\n", sizeof current_task()->name, current_task()->name, name);
                        if (mach_port_deallocate_debug)
                                SoftDebugger("mach_port_deallocate");
@@ -614,7 +614,7 @@ mach_port_deallocate(
 
        kr = ipc_right_lookup_write(space, name, &entry);
        if (kr != KERN_SUCCESS) {
-               if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space 
== current_space()) {
+               if (MACH_PORT_VALID (name) && space == current_space()) {
                        printf("task %.*s deallocating an invalid port %lu, 
most probably a bug.\n", sizeof current_task()->name, current_task()->name, 
name);
                        if (mach_port_deallocate_debug)
                                SoftDebugger("mach_port_deallocate");
@@ -735,8 +735,19 @@ mach_port_mod_refs(
                return KERN_INVALID_VALUE;
 
        kr = ipc_right_lookup_write(space, name, &entry);
-       if (kr != KERN_SUCCESS)
+       if (kr != KERN_SUCCESS) {
+               if (MACH_PORT_VALID (name) && space == current_space()) {
+                       printf("task %.*s %screasing an invalid port "
+                              "%lu by %d, most probably a bug.\n",
+                              sizeof current_task()->name,
+                              current_task()->name,
+                              delta < 0 ? "de" : "in", name,
+                              delta < 0 ? -delta : delta);
+                       if (mach_port_deallocate_debug)
+                               SoftDebugger("mach_port_mod_refs");
+               }
                return kr;
+       }
        /* space is write-locked and active */
 
        kr = ipc_right_delta(space, name, entry, right, delta); /* unlocks */
-- 
2.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]