From 383379ae770fd6a74c592006f46986320df9fa30 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 18 Nov 2023 21:36:44 +0100 Subject: ipc_entry_lookup: Generalize warnings about bogus port names Looking up a bogus port name is generally a sign of a real bug, such as a spurious mach port deallocation. --- ipc/ipc_kmsg.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'ipc/ipc_kmsg.c') diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index fb8de249..096769f2 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -686,7 +686,10 @@ ipc_kmsg_copyin_header( entry = ipc_entry_lookup (space, dest_name); if (entry == IE_NULL) + { + ipc_entry_lookup_failed (dest_name); goto abort_async; + } bits = entry->ie_bits; /* check type bits */ @@ -738,7 +741,10 @@ ipc_kmsg_copyin_header( entry = ipc_entry_lookup (space, dest_name); if (entry == IE_NULL) + { + ipc_entry_lookup_failed (dest_name); goto abort_request; + } bits = entry->ie_bits; /* check type bits */ @@ -752,7 +758,10 @@ ipc_kmsg_copyin_header( entry = ipc_entry_lookup (space, reply_name); if (entry == IE_NULL) + { + ipc_entry_lookup_failed (reply_name); goto abort_request; + } bits = entry->ie_bits; /* check type bits */ @@ -819,7 +828,10 @@ ipc_kmsg_copyin_header( entry = ipc_entry_lookup (space, dest_name); if (entry == IE_NULL) + { + ipc_entry_lookup_failed (dest_name); goto abort_reply; + } bits = entry->ie_bits; /* check and type bits */ @@ -892,6 +904,8 @@ ipc_kmsg_copyin_header( if (((entry = ipc_entry_lookup(space, notify)) == IE_NULL) || ((entry->ie_bits & MACH_PORT_TYPE_RECEIVE) == 0)) { + if (entry == IE_NULL) + ipc_entry_lookup_failed (notify); is_write_unlock(space); return MACH_SEND_INVALID_NOTIFY; } @@ -916,8 +930,10 @@ ipc_kmsg_copyin_header( */ entry = ipc_entry_lookup(space, name); - if (entry == IE_NULL) + if (entry == IE_NULL) { + ipc_entry_lookup_failed (name); goto invalid_dest; + } assert(reply_type != 0); /* because name not null */ @@ -1067,8 +1083,10 @@ ipc_kmsg_copyin_header( */ entry = ipc_entry_lookup(space, dest_name); - if (entry == IE_NULL) + if (entry == IE_NULL) { + ipc_entry_lookup_failed (dest_name); goto invalid_dest; + } kr = ipc_right_copyin(space, dest_name, entry, dest_type, FALSE, @@ -1123,12 +1141,17 @@ ipc_kmsg_copyin_header( */ dest_entry = ipc_entry_lookup(space, dest_name); - if (dest_entry == IE_NULL) + if (dest_entry == IE_NULL) { + ipc_entry_lookup_failed (dest_name); goto invalid_dest; + } reply_entry = ipc_entry_lookup(space, reply_name); if (reply_entry == IE_NULL) + { + ipc_entry_lookup_failed (reply_name); goto invalid_reply; + } assert(dest_entry != reply_entry); /* names are not equal */ assert(reply_type != 0); /* because reply_name not null */ @@ -2093,6 +2116,8 @@ ipc_kmsg_copyout_header( if (((entry = ipc_entry_lookup(space, notify)) == IE_NULL) || ((entry->ie_bits & MACH_PORT_TYPE_RECEIVE) == 0)) { + if (entry == IE_NULL) + ipc_entry_lookup_failed (notify); is_read_unlock(space); return MACH_RCV_INVALID_NOTIFY; } -- cgit v1.2.3