Skip to content

Conversation

@vcheckin-uptycs
Copy link
Contributor

Experiencing random crashes in iokit thread on USB unplug.

Crashed Thread:        22  iokit

Exception Type:        EXC_GUARD (SIGKILL)
Exception Codes:       GUARD_TYPE_MACH_PORT
Exception Codes:       0x0000000000005c03, 0x0000000000000000
...
Thread 22 Crashed:: iokit
0   libsystem_kernel.dylib        	       0x18da69ce4 _kernelrpc_mach_port_deallocate_trap + 8
1   libsystem_kernel.dylib        	       0x18da6b11c mach_port_deallocate + 28
2   IOKit                         	       0x191536678 IODispatchCalloutFromCFMessage + 396
3   CoreFoundation                	       0x18dbbf1d0 __CFMachPortPerform + 296
4   CoreFoundation                	       0x18db922c8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
5   CoreFoundation                	       0x18db921e8 __CFRunLoopDoSource1 + 524
6   CoreFoundation                	       0x18db90b48 __CFRunLoopRun + 2248
7   CoreFoundation                	       0x18db8fbc4 CFRunLoopRunSpecific + 588
8   CoreFoundation                	       0x18dc0ae50 CFRunLoopRun + 64

This PR aims to fix couple of refcounting issues in iokit.cpp:

  1. IOObjectRelease(device) is called in some paths of DeleteDevice. The callback operates on a "borrowed" reference and shouldn't release it.
  2. IOReleaseObject(notification) is called twice. Converting to RAII style management of notification object.

@vcheckin-uptycs vcheckin-uptycs requested review from a team as code owners November 26, 2024 19:34
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 26, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

directionless
directionless previously approved these changes Dec 1, 2024
@directionless directionless merged commit 717749d into osquery:master Dec 12, 2024
22 checks passed
@vcheckin-uptycs vcheckin-uptycs deleted the iokit-refcount branch December 17, 2024 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants