PCI driver Migrating from IOKit kext to Driverkit dext issues

∥☆過路亽.° 提交于 2020-12-15 05:34:10

问题


I'm migrating my PCI driver from iokit to dext using PCIDriverkit. I download the "MyUserUSBInterfaceDriver" sample, modify compile, sign, and run. the dext can load, but there are many errors:

kernel: serviceMatchesCDHash: required cdhash 3...3 in personality does not match service kernel: DK: IOUserServer(sc.knight.MyUserUSBInterfaceDriver-0x1000064ac)::exit(CDHash check failed) kernel:

(above:This error Repeat 5 times) ............ ............ ............ ............ ............ ............ ............ ....

kernel: (sc.knight.MyUserUSBInterfaceDriver.dext) test init init

kernel: (sc.knight.MyUserUSBInterfaceDriver.dext) test init init finish 1

kernel: (sc.knight.MyUserUSBInterfaceDriver.dext) kernel: (AppleMobileFileIntegrity) AMFI: SIP is off, allowing core dump for pid 9259 (sc.knight.MyUser) kernel: (AppleMobileFileIntegrity) AMFI: SIP is off, allowing core dump for pid 9259 (sc.knight.MyUser)

ReportCrash: Parsing corpse data for pid 9259

ReportCrash: Parsing corpse data for process sc.knight.MyUser [pid 9259]

ReportCrash: (AppStoreFoundation) [com.apple.appstorefoundation:Default] Error reading receipt: Error Domain=NSCocoaErrorDomain Code=260 "The file “receipt” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Library/SystemExtensions/0...0/sc.knight.MyUserUSBInterfaceDriver.dext//Contents/_MASReceipt/receipt, NSUnderlyingError=0x7fcc681d4b70 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

(above:The driver's init() function is called, and Repeat many times)

............ ............ ............ ............ ............ ............ ............ ....

kernel: (sc.knight.MyUserUSBInterfaceDriver.dext) test init init

kernel: (sc.knight.MyUserUSBInterfaceDriver.dext) test init init finish 1

kernel: (sc.knight.MyUserUSBInterfaceDriver.dext) kernel: (AppleMobileFileIntegrity) AMFI: SIP is off, allowing core dump for pid 10191 (sc.knight.MyUser) kernel: Process[10191] crashed: sc.knight.MyUser. Too many corpses being created. kernelmanagerd: Received kext load notification: (above:this is the last error)

....................................................................

Here is my entitlement

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.developer.driverkit</key>
    <true/>
    <key>com.apple.developer.driverkit.transport.pci</key>
    <array>
        <dict>
            <key>IOPCIPrimaryMatch</key>
            <string>0xbbbbaaaa</string>
        </dict>
    </array>
</dict>
</plist>

This is my info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>OSBundleUsageDescription</key>
    <string>Example user space PCI driver</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>IOKitPersonalities</key>
    <dict>
        <key>MyUserUSBInterfaceDriver</key>
        <dict>
            <key>IOResourceMatch</key>
            <string>IOKit</string>
            <key>IOMatchCategory</key>
            <string>IOService</string>
            <key>IOPCITunnelCompatible</key>
            <true/>
            <key>CFBundleIdentifier</key>
            <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
            <key>IOClass</key>
            <string>IOService</string>
            <key>ProductID</key>
            <integer>bbbb</integer>
            <key>VendorID</key>
            <integer>aaaa</integer>
            <key>IOProviderClass</key>
            <string>IOPCIDevice</string>
            <key>IOPCIPrimaryMatch</key>
            <string>0xaaaabbbb</string>
            <key>bConfigurationValue</key>
            <integer>1</integer>
            <key>IOUserClass</key>
            <string>MyUserUSBInterfaceDriver</string>
            <key>IOUserServerName</key>
            <string>sc.knight.MyUserUSBInterfaceDriver</string>
        </dict>
    </dict>
</dict>
</plist>

This is part of source code.

class MyUserUSBInterfaceDriver: public IOService

boolMyUserUSBInterfaceDriver::init()
{
    bool result = false;

    os_log(OS_LOG_DEFAULT, "test %{public}s init", __FUNCTION__);

    result = super::init();
    ivars = IONewZero(MyUserUSBInterfaceDriver_IVars, 1);

    os_log(OS_LOG_DEFAULT, "test %{public}s init finish %{public}d", __FUNCTION__, result);
Exit:
    return result;
}

I have 2 questions.

1, "required cdhash in personality does not match service", what does that mean? Wrong entitlement format?

2,why my dext crashed ? The init() function is called, but crash before start() is called, did I miss something or did something wrong?

Many thanks for any help.

来源:https://stackoverflow.com/questions/62874309/pci-driver-migrating-from-iokit-kext-to-driverkit-dext-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!