Hi there,
While developing my first kernel extension for a learning purpose, I'm facing the issue above, "Bad code signature".
The actual steps to reproduce are as follows: \
- Initialize my Xcode project using the template "Generic Kernel Extension".
- Implement a fundamental extension that displays "Hello World!" using
printf();
. - Build and sign it as "Sign to run locally".
- Put the "HelloWorld.kext" bundle into the
/Library/Extensions/
. - Change the owner of the bundle file to "root:wheel".
- Load the extension using as follows.
$ cd /Library/Extentions
$ sudo kextload /Library/Extensions/HelloWorld.kext
Password:
Executing: /usr/bin/kmutil load -p /Library/Extensions/HelloWorld.kext
Error Domain=KMErrorDomain Code=29 "Authenticating extension failed: Kext com.martymarron.HelloWorld v.1.0.0 in executable kext bundle com.martymarron.HelloWorld at /Library/Extensions/HelloWorld.kext:
Authenticating extension failed: Bad code signature" UserInfo={NSLocalizedDescription=Authenticating extension failed: Kext com.martymarron.HelloWorld v1.0.0 in executable kext bundle com.martymarron.HelloWorld at /Library/Extensions/HelloWorld.kext:
Authenticating extension failed: Bad code signature}
I guessed that the bundle needs to be signed anyway. Hence I signed it for "development", but it resulted in the same. Some article says that my developer account should be enabled for "KEXT development" on https://developer.apple.com/resources/developer-id/, but this link does not work now. Referred article: https://developer.apple.com/forums/thread/30703
Then, I found the article below says "the kernel doesn't load a kext if an equivalent System Extention solution exists". https://developer.apple.com/documentation/kernel/implementing_drivers_system_extensions_and_kexts
Does this mean the kernel extension development on my environment is no longer supported? Or is there still the way to try the kernel extension development on my environment? If no, I'll give up trying it and will try "system extension development" instead.
Thanks for your kind help!
My development environment:
- OS ver: Monterey(12.5)
- CPU Arch: Intel Core i7
- Xcode ver: Version 13.4.1 (13F100)
this link does not work now
Yeah, that’s annoying (more annoying is that I can’t fix the link)-: Anyway, the latest version of that page is here.
Does this mean the kernel extension development on my environment is no longer supported?
macOS will still load some third-party KEXTs. For this to work in production:
-
The relevant subsystem must still use KEXTs. For example:
-
The network subsystem no longer loads network kernel extensions (NKEs) because those have been disabled in favour of Network Extension providers.
-
The VFS subsystem still supports KEXTs, although at some point those are likely to go away in terms of file providers.
-
On the I/O Kit front, much of that support has migrated to DriverKit.
-
-
The KEXT must be signed with a KEXT-enabled Developer ID. For more on that, see KEXT Code Signing Problems.
-
The KEXT must be notarised.
During development you can avoid the need for a KEXT-enabled Developer ID by disabling SIP.
What are you trying to do with a KEXT? Our general advice has always been that you avoid writing code for the kernel if at all possible. Indeed, the first section of the Kernel Programming Guide is entitlement Keep Out! These days you have a wealth of alternatives and it’s best to explore those first.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"