我正在尝试测试一个实现过滤器方案的 IO 套件示例应用程序。有关上下文,请参见此处的第10.7.10节。由于源代码很难剪切和粘贴(当我尝试时出现错误),我使用的是来自这里的源代码。
在该页面的最后一个图 (1038) 中,它包含一系列用于创建和安装新 HFS 卷的步骤。这个想法是看到 KEXT 正在工作并进行加密。我已经构建了示例 KEXT 并对其进行了测试,但是当我进行“打开”调用时,我总是收到“无法安装的文件系统”错误。我已验证 KEXT 已正确加载。
如果我删除“-partitionType”,我可以正常操作卷(尽管这不涉及 KEXT)。
有人可以建议这里可能出了什么问题吗?
我对图 1038 脚本的部分困惑是在打开之前运行的“分离”命令。它对我来说失败了,但我不确定这是否是导致它失败后“打开”的原因,或者是无关的。
$ sudo kextload /System/Library/Extensions/IOKitDriverTestApp.kext/
$ hdiutil create -size 32m -partitionType osxbook_HFS /tmp/crypto.dmg
created: /tmp/crypto.dmg
$ hdiutil attach -nomount /tmp/crypto.dmg
/dev/disk2 Apple_partition_scheme
/dev/disk2s1 Apple_partition_map
/dev/disk2s2 osxbook_HFS
$ diskutil list
/dev/disk0 (internal, physical):
[cut]
/dev/disk1 (synthesized):
[cut]
/dev/disk2 (disk image):
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme +33.6 MB disk2
1: Apple_partition_map 32.3 KB disk2s1
2: osxbook_HFS 33.5 MB disk2s2
$ newfs_hfs -v Crypto /dev/rdisk2s2
Initialized /dev/rdisk2s2 as a 32 MB case-insensitive HFS Plus volume
$ hdiutil detach /dev/disk2
hdiutil: detach failed - No such file or directory
$ open /tmp/crypto.dmg
==> Get popup window with error "crypto.dmg" "No mountable file systems"
更新:问题最初针对未加载 KEXT 的情况。自从我让它工作后,我改变了它以反映 KEXT 的情况,无论如何这更重要。
UPDATE2:似乎最终 kext 正在卸载(可能崩溃)。有时它似乎在“开放”的时候左右,有时在之后。我尝试添加像 IOLog("CSD: init") 这样的语句,但它们都没有出现在系统日志或控制台日志中。寻找我还能如何分类这个(不需要单独的机器)。
UPDATE3:下面是我尝试启动 KEXT 时的输出。有很多警告,但由于我禁用了签名检查,我认为它仍在加载。我还看到它是通过 kextstat 加载的。
另一个奇怪的事情是我在“ioreg”的输出中没有看到这个 KEXT 的任何迹象,也没有看到来自 IOLog() 的任何打印语句。
My-MacBook-Pro:Extensions myuser$ sudo kextutil -v /System/Library/Extensions/IOKitDriverTestApp.kext/
Defaulting to kernel file '/System/Library/Kernels/kernel'
Kext with invalid signatured (-67050) allowed: <OSKext 0x7fa53703ec70 [0x7fff8fe6faf0]> { URL = "file:///System/Library/Extensions/IOKitDriverTestApp.kext/", ID = "com.osxbook.driver.IOKitDriverTestApp" }
Code Signing Failure: code signature is invalid
Warnings:
Personality CFBundleIdentifier differs from containing kext's (not necessarily a mistake, but rarely done):
SimpleCryptoDisk
Personality CFBundleIdentifier names a kext that can't be found:
'SimpleCryptoDisk' -> 'com.osxbook.driver.SimpleCryptoDisk'
Warnings:
Personality CFBundleIdentifier differs from containing kext's (not necessarily a mistake, but rarely done):
SimpleCryptoDisk
Personality CFBundleIdentifier names a kext that can't be found:
'SimpleCryptoDisk' -> 'com.osxbook.driver.SimpleCryptoDisk'
/System/Library/Extensions/IOKitDriverTestApp.kext appears to be loadable (not including linkage for on-disk libraries).
Loading /System/Library/Extensions/IOKitDriverTestApp.kext.
/System/Library/Extensions/IOKitDriverTestApp.kext successfully loaded (or already loaded).
Invalid signature -67050 for kext <OSKext 0x7fa53703ec70 [0x7fff8fe6faf0]> { URL = "file:///System/Library/Extensions/IOKitDriverTestApp.kext/", ID = "com.osxbook.driver.IOKitDriverTestApp" }
UPDATE4:我调整了 plist 中的捆绑 ID 使其匹配,现在它没有给出“无法找到的名称”错误:
My-MacBook-Pro:Debug myuser$ sudo kextutil -v /System/Library/Extensions/IOKitDriverTestApp.kext/
Password:
Defaulting to kernel file '/System/Library/Kernels/kernel'
Kext with invalid signatured (-67050) allowed: <OSKext 0x7f8be663ecf0 [0x7fff866bcaf0]> { URL = "file:///System/Library/Extensions/IOKitDriverTestApp.kext/", ID = "com.osxbook.driver.IOKitDriverTestApp" }
Code Signing Failure: code signature is invalid
/System/Library/Extensions/IOKitDriverTestApp.kext appears to be loadable (not including linkage for on-disk libraries).
Loading /System/Library/Extensions/IOKitDriverTestApp.kext.
/System/Library/Extensions/IOKitDriverTestApp.kext successfully loaded (or already loaded).
Invalid signature -67050 for kext <OSKext 0x7f8be663ecf0 [0x7fff866bcaf0]> { URL = "file:///System/Library/Extensions/IOKitDriverTestApp.kext/", ID = "com.osxbook.driver.IOKitDriverTestApp" }
更新5:
现在,每次我加载 KEXT 然后执行“hdiutil attach -nomount /tmp/crypto.dmg”(在创建 /tmp/crypto.dmg 之后)时,我的操作系统都会崩溃。
很明显我的 KEXT 现在正在运行,但由于某种原因,我仍然没有在任何地方看到 IOLog() 语句。必须查看系统日志,看看是否有任何迹象表明它崩溃了。
UPDATE6:我已经能够获得象征性的内核恐慌,但它指向不同的 KEXT(我认为我也没有源代码)。下面是它的相关部分。
我尝试使用相同测试 KEXT 的另一个版本(此处)而不进行任何更改(我已经删除了 IOLog() 语句,因为它们没有出现)。
我看到一个注释,这是在 Mac OS 10.6 上测试的,但是有没有人让这个样本在 10.13.16 (High Sierra) 上工作?
...
0xffffff800c94f540 : 0xffffff800cb8776f mach_kernel : _kernel_trap + 0x70f
0xffffff800c94f6b0 : 0xffffff800ca1e1e0 mach_kernel : _return_from_trap + 0xe0
0xffffff800c94f6d0 : 0xffffff7f8d527251 com.apple.iokit.IOStorageFamily : __ZN9IOStorage8completeEP19IOStorageCompletioniy + 0x27
0xffffff81f7a4b980 : 0xffffff7f8d51a0c4 com.apple.iokit.IOStorageFamily : __ZN20IOBlockStorageDriver24prepareRequestCompletionEPvS0_iy + 0xc2
0xffffff81f7a4b9e0 : 0xffffff7f903afa7a com.apple.driver.DiskImages : __ZN13IOHDIXCommand8completeEiy + 0x26
0xffffff81f7a4ba00 : 0xffffff7f903adbfe com.apple.driver.DiskImages : __ZN22IOHDIXHDDriveOutKernel12processReplyEPK13HDIReplyOOL64P18IOMemoryDescriptor + 0x2be
0xffffff81f7a4ba60 : 0xffffff7f903aee9b com.apple.driver.DiskImages : __ZN32IOHDIXHDDriveOutKernelUserClient14processReply64EPK13HDIReplyOOL64 + 0xd3
0xffffff81f7a4bac0 : 0xffffff800d0c3959 mach_kernel : _shim_io_connect_method_structureI_structureO + 0x1c9
0xffffff81f7a4bb20 : 0xffffff800d0c1ae0 mach_kernel : __ZN12IOUserClient14externalMethodEjP25IOExternalMethodArgumentsP24IOExternalMethodDispatchP8OSObjectPv + 0x340
0xffffff81f7a4bb70 : 0xffffff800d0ca567 mach_kernel : _is_io_connect_method + 0x217
...
UPDATE7:我放弃了尝试使用 SimpleCryptoDisk.cpp 测试应用程序并从头开始,一次添加一点代码。我已经取得了一些成功(驱动程序启动并且我可以看到日志记录),尽管我还没有任何工作。
如果我被困在这个问题上,我可能会发布另一个问题,但我会继续将 pmdj 的答案标记为正确,因为他回答了我原来的问题。
但是,如果有人知道适用于 High Sierra 的 SimpleCryptoDisk 的修改版本,我仍然想知道。