openzfsonosx / openzfs

OpenZFS on Linux and FreeBSD, and, macOS. This is where development for macOS happens.
https://github.com/openzfs/zfs/wiki
Other
144 stars 10 forks source link

Kernel Extension Won't Load on macOS Sequoia #129

Open dmzimmerman opened 2 months ago

dmzimmerman commented 2 months ago

System information

Type | Version/Name macOS | Sequoia Developer Beta 1 (24A5264n) ZFS Version | 2.2.3 rc1 (Apple Silicon)

Describe the problem you're observing

The kernel extension does not load on macOS Sequoia, because it can't link to an implementation of _sprintf. Here's what it says when trying to manually kextload it on the command line:

Error Domain=KMErrorDomain Code=31 "Error occurred while building a collection:
    1: One or more binaries has an error which prevented linking.  See other errors.
    2: Could not use 'org.openzfsonosx.zfs' because: Failed to bind '_sprintf' in 'org.openzfsonosx.zfs' (at offset 0x558 in __DATA_CONST, __auth_got) as could not find a kext which exports this symbol
org.openzfsonosx.zfs specific:
    1: Failed to bind '_sprintf' in 'org.openzfsonosx.zfs' (at offset 0x558 in __DATA_CONST, __auth_got) as could not find a kext which exports this symbol
" UserInfo={NSLocalizedDescription=Error occurred while building a collection:
    1: One or more binaries has an error which prevented linking.  See other errors.
    2: Could not use 'org.openzfsonosx.zfs' because: Failed to bind '_sprintf' in 'org.openzfsonosx.zfs' (at offset 0x558 in __DATA_CONST, __auth_got) as could not find a kext which exports this symbol
org.openzfsonosx.zfs specific:
    1: Failed to bind '_sprintf' in 'org.openzfsonosx.zfs' (at offset 0x558 in __DATA_CONST, __auth_got) as could not find a kext which exports this symbol
}

I can't imagine that it's going to be too hard to make the jump to Sequoia in general - they didn't announce any major changes to kernel extensions as far as I've been able to find - but clearly there are some minor issues, at least.

Describe how to reproduce the problem

Install OpenZFS on Sequoia and try to load the kernel extension.

lundman commented 2 months ago

Awesome, we shouldn't be calling sprintf anyway, I've been frustrated with Linux devs adding more of them. (We should be calling snprintf)

I'll grab the beta, and roll out a build with a fix and see if other things break.

lundman commented 2 months ago

While I wait for VM to install, I produced: https://openzfsonosx.org/forum/viewtopic.php?f=20&t=3896

I have not yet tested it, but all I did was change sprintf() calls into snprintf() should you feel interested in testing it. If you get a boot-loop, just run the --trigger-panic-medic

dmzimmerman commented 2 months ago

Excellent. Sadly, I won't get back to a machine where I can test it for a few hours, but I'll try it when I do (unless your VM reveals other problems first).

lundman commented 2 months ago

Hmm remotely I can only do i386 VMs (thanks apple!) but I can at least check sprintf is fixed.

dmzimmerman commented 2 months ago

Well, I actually got away for a couple of minutes to try it, and the kext seems to load fine. Of course I have no ZFS pools on this machine yet so I don't know what'll happen when I try to actually use one, but at least no boot loop.

lundman commented 2 months ago

create an empty file: mkfile -n 1G /var/tmp/pool.img and create a pool on it? I mean, if you wanted to :)

lundman commented 2 months ago

Assuming /var/tmp is still writable, not sure if macOS made them all readonly

dmzimmerman commented 2 months ago

That seems to work fine. I copied some disk images to it, mounted them, they seemed to work. That bodes well. Don't have time for any more detailed testing right now, though, I'm afraid.

lundman commented 2 months ago

Awesome, thanks for your report