Page MenuHomePhabricator

[Platform] Accept arbitrary kext variants
ClosedPublic

Authored by JDevlieghere on May 30 2018, 9:01 AM.

Details

Summary

When loading kexts in PlatformDarwinKernel, we use the BundleID as the filename to to create shared modules. In GetSharedModule we call ExamineKextForMatchingUUID for any BundleID it finds that is a match, to see if the UUID is also a match. Until now we were using Host::ResolveExecutableInBundle whcih calls a CoreFoundation API to obtain the executable. However, it's possible that the executable has a variant suffix (e.g. foo_development) and these files were ignored.

This patch replaces that call with logic that looks for all the binaries in the bundle. Because of the way ExamineKextForMatchingUUID works, it's fine to try to load executables that are not valid and we can just iterate over the list until we found a match.

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.May 30 2018, 9:01 AM

Don't use EnumerateDirectory

LGTM. If we added more knowledge specifically about kext bundle layouts, we could restrict which files we test to see if they are valid binaries - but we'd need to parse the Info.plist at the top (to get the CFBundleExecutable name, and look for variations on that prefix) and we'd need to handle shallow/deep kext bundles. Given how few files are in kext bundles besides the kexts themselves (a couple of plists), this is code is much simpler than encoding all that extra specifics about kexts.

LGTM. If we added more knowledge specifically about kext bundle layouts, we could restrict which files we test to see if they are valid binaries - but we'd need to parse the Info.plist at the top (to get the CFBundleExecutable name, and look for variations on that prefix) and we'd need to handle shallow/deep kext bundles. Given how few files are in kext bundles besides the kexts themselves (a couple of plists), this is code is much simpler than encoding all that extra specifics about kexts.

Thanks Jason!

Currently there are no kext test currently. Jason and I had a brief discussion yesterday on how we could do this in the future, but while it is certainly possible (and something I want to do) it's going to be too much work for this small change. Unless anyone has a practical idea for a test I'm going to land this as is, awaiting the aforementioned kext test infrastructure.

JDevlieghere edited the summary of this revision. (Show Details)May 31 2018, 2:24 AM
This revision was not accepted when it landed; it landed in state Needs Review.Jun 7 2018, 9:15 AM
Closed by commit rL334205: [Platform] Accept arbitrary kext variants (authored by JDevlieghere, committed by ). · Explain Why
This revision was automatically updated to reflect the committed changes.