Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kext does not load on 10.16 Big Sur #8

Closed
lundman opened this issue Jun 26, 2020 · 18 comments
Closed

kext does not load on 10.16 Big Sur #8

lundman opened this issue Jun 26, 2020 · 18 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@lundman
Copy link
Contributor

lundman commented Jun 26, 2020

Appears to be related to the Plugins/KernelDependencies.kext/ that we have to link against things we are not allowed to link against.

A straight load attempt fails with:

Error: Error Domain=KMErrorDomain Code=1 "Unable to resolve dependencies: 'net.lundman.zfs' names a 
dependency on 'net.lundman.kernel.dependencies.0.8.0', which was not found." UserInfo=
 {NSLocalizedDescription=Unable to resolve dependencies: 'net.lundman.zfs' names a dependency on
 'net.lundman.kernel.dependencies.0.8.0', which was not found.}

As if it doesn't look in Plugins anymore. However, when if I attempt to codesign the Plugins kext;

codesign_allocate: can't allocate code signature data for: 
/private/tmp/zfs.kext/Contents/PlugIns/KernelExports.kext/KernelExports (for architecture x86_64) because 
file does not have a __LINKEDIT segment

Which makes me think that they've made a slight change to the requirements of kexts, and kextsymboltool no
longer produces a valid object file.

Similarly, if I try to load the 1.9.4 signed/notarized kexts:

 "Error occurred while building cache:
in '/Library/Extensions/spl.kext/Contents/PlugIns/KernelExports.kext/KernelExports' missing __TEXT segment"

So I think we need to figure out how to make the output of kextsymboltool be accepted under Big Sur.

In addition, the output from kextload/kextutil is not exactly great - the real errors must go somewhere?

@lundman lundman added bug Something isn't working help wanted Extra attention is needed labels Jun 26, 2020
@lundman
Copy link
Contributor Author

lundman commented Jun 26, 2020

# file kernelexports
kernelexports: Mach-O universal binary with 2 architectures: [i386:Mach-O object i386] [x86_64:Mach-O 64-bit kext bundle x86_64]
kernelexports (for architecture i386):  Mach-O object i386
kernelexports (for architecture x86_64):        Mach-O 64-bit kext bundle x86_64


#  clang++ -g -O2 -Wl,-kext -nostdlib -o zfs ./kernelexports -lkmodc++ -lkmod -lcc_kext
ld: warning: ignoring file ./kernelexports, file is universal (2 slices) but does not contain the x86_64 architecture:
 ./kernelexports

and that's on Catalina even.

@lundman
Copy link
Contributor Author

lundman commented Jul 3, 2020

Hmm hey @meklort - you showed us this trickery the first time around, any ideas?

@meklort
Copy link

meklort commented Jul 3, 2020

I haven't looked into the newer OSes much, so I can't really say. I'd suggest looking at the symbol kexts included by Apple and seeing how those have changed from before. I wouldn't be surprised if they are now either signed or have some changed to the plist.

There may also be an updated symbol tool that you'll need to use to generate the Mach-O binary with.

@lundman
Copy link
Contributor Author

lundman commented Jul 3, 2020

I think they changed kextsymboltool.c a fair bit, but unfortunately they don't release the XNU sources until a few months after the OS is out, and it would be nice if it worked before then. No other kexts on the OS has Plugins/ directory inside, so it is possible they removed the feature entirely, and we've had to sign the codeless plugin since 10.11.

I've asked Apple if I can have kextsymboltool.c , but it was met with silence.

@lundman
Copy link
Contributor Author

lundman commented Jul 3, 2020

Received DTK today, to also try to make it work for ARM64.
Homebrew isn't quite there, Homebrew/brew#7857
but they are making great progress.

Although even after compiling, we still have the kext loading issue.

@lundman
Copy link
Contributor Author

lundman commented Jul 8, 2020

OK, so exploring dynamically looking up the modules on kext init, which generally works, except the current way to lookup vm_kernel_slide is a bit off, +0c000 is needed in my example:

    vm_offset_t func_address = (vm_offset_t) vm_kernel_unslide_or_perm_external;
    vm_offset_t func_address_unslid = 0;
    vm_kernel_unslide_or_perm_external(func_address, &func_address_unslid);
    vm_kern_slide = func_address - func_address_unslid;
    printf("Kernel slide: %lx\n", vm_kern_slide);
Kernel slide: 0x0000000028400000

lldb:
KernelCache slide: 0x0000000028400000
KernelCache base:  0xffffff8028600000
Kernel slide:      0x000000002840c000
Kernel text base:  0xffffff802860c000
__HIB  text base: 0xffffff8028500000

However, hardcoding the difference:

    kern_base = KERN_TEXT_BASE + vm_kern_slide + 0xc000;

[   12.874118]: spl_loadsymbols: failed to locate '_fp_drop'
[   12.874759]: spl_loadsymbols: failed to locate '_fp_drop_written'
[   12.875355]: spl_loadsymbols: failed to locate '_fp_lookup'
[   12.875936]: spl_loadsymbols: failed to locate '_fo_read'
[   12.876511]: spl_loadsymbols: failed to locate '_fo_write'
[   12.877708]: spl_loadsymbols: Loaded 23, failed 5.

@lundman
Copy link
Contributor Author

lundman commented Jul 8, 2020

The Intel Big Sur VM does start the kext without those functions, obviously with some features missing.

DTK loading does not yet work.

@lundman
Copy link
Contributor Author

lundman commented Jul 17, 2020

There is now a Big Sur x64 build, no missing features. No arm64 yet.
https://twitter.com/JorgenLundman/status/1283602297344258053

@lin7sh
Copy link

lin7sh commented Aug 7, 2020

Will Kext support eventually remove by Apple, Is it possible for zfs on Mac switch to Apple System extension like DriverKit?

@captain-haddock17
Copy link

Hi all !

Did some searching about VFS (kext) and FileProvider (userland) on macOS Catalina & 'Big Sur'.
Found that FileProvider (macOS) will/(will only be ?) on macOS.11 'Big Sur', but is not yet stable/complete...
:-(
Although with Apple's security concern, I'm guessing FileProvider [Extension] will be the only way to make ZFS "drives" appear on our next macOS.11 Big Sur.
https://developer.apple.com/documentation/fileprovider/macos_support

See Apple Dev Forum Cannot launch new FileProvider extension on macOS 10.15

After checking it out in macOS 11 Beta 4 and Xcode 12 Beta 4:
There is no option to add a File Provider extension target to a macOS app
The documentation has a macOS support section but lacks actual documentation on how it should be used
The documentation says the NSFileProviderExtension class is only available on iOS

and

NSFileProviderExtension' is unavailable in macOS.
Confirmed in macOS 11 Beta 4(Xcode 12 Beta 4)

@lundman : did you already submit a dev feedback ?
HTH
William

@yurikoles
Copy link

There is now a Big Sur x64 build, no missing features. No arm64 yet.
https://twitter.com/JorgenLundman/status/1283602297344258053

I have a KP with this build on Big Sur 11.0.1.

@cabrinha
Copy link

cabrinha commented Dec 6, 2020

There is now a Big Sur x64 build, no missing features. No arm64 yet.
https://twitter.com/JorgenLundman/status/1283602297344258053

I have a KP with this build on Big Sur 11.0.1.

I downloaded the package from the tweet. How did you install/load this up?

When trying to import, I get:

dyld: Symbol not found: _aok
  Referenced from: /Users/yuppie/Downloads/openzfsonosx-bigsur/usr/local/sbin/zpool
  Expected in: /usr/local/lib/libuutil.1.dylib
 in /Users/yuppie/Downloads/openzfsonosx-bigsur/usr/local/sbin/zpool

@yurikoles
Copy link

I downloaded the package from the tweet. How did you install/load this up?

When trying to import, I get:

dyld: Symbol not found: _aok
  Referenced from: /Users/yuppie/Downloads/openzfsonosx-bigsur/usr/local/sbin/zpool
  Expected in: /usr/local/lib/libuutil.1.dylib
 in /Users/yuppie/Downloads/openzfsonosx-bigsur/usr/local/sbin/zpool

The contents of this zip archive is intended to be extracted to the root of your system/boot volume.

@cabrinha
Copy link

cabrinha commented Dec 6, 2020

I downloaded the package from the tweet. How did you install/load this up?
When trying to import, I get:

dyld: Symbol not found: _aok
  Referenced from: /Users/yuppie/Downloads/openzfsonosx-bigsur/usr/local/sbin/zpool
  Expected in: /usr/local/lib/libuutil.1.dylib
 in /Users/yuppie/Downloads/openzfsonosx-bigsur/usr/local/sbin/zpool

The contents of this zip archive is intended to be extracted to the root of your system/boot volume.

Does this mean that I can install OpenZFS 1.9.4 and just extract this zip to /System?

I see that there is a 2.0.0 release and also branches for big-sur, but I don't see any 2.0.0 DMG installer.

I'm currently running Big Sur and can't import my volumes.

Any instructions on how to get this working would be very helpful.

@glessard
Copy link

glessard commented Dec 6, 2020

The openzfs-on-osx forums are a better place to get releases:
https://openzfsonosx.org/forum/viewtopic.php?f=20&t=3478

That topic has links to proper installer files since earlier this week.

@gssdromen
Copy link

xxx@xxx-Air  ~  sudo zpool import -f disk
Password:
The ZFS modules are not loaded.
Try running '/sbin/kextload zfs.kext' as root to load them.
✘ xxx@xxx-Air  ~  sudo su
sh-3.2# /sbin/kextload zfs.kext
Executing: /usr/bin/kmutil load -p /Users/xxx/zfs.kext
Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"

No such file or directory after install 2.0 openzfs for big sur

@lundman
Copy link
Contributor Author

lundman commented Jan 5, 2021

The openzfs-2.0 installer requires you to set "keepsyms=1" for it to load. This was the only work-around for this issue that we could find so far.

@lundman
Copy link
Contributor Author

lundman commented Apr 21, 2021

pure is about to be pushed.

@lundman lundman closed this as completed Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants