Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use _CFURLConnectionSetFrameworkStubs instead of DYLD_INTERPOSE on In…
…tel Macs

https://bugs.webkit.org/show_bug.cgi?id=218810

Patch by Alex Christensen <achristensen@webkit.org> on 2020-11-11
Reviewed by Geoffrey Garen.

A long, long time ago, we realized that CFNetwork was looking in the keychain for persistent credentials,
and in order to make the network process get credentials as the UI process, we introduced SecItemShim which
used DYLD_INTERPOSE to intercept the calls to the security framework and synchronously message the UI process
for those calls.  Over the last 6 years we have realized that doesn't work on iOS or Apple silicon Macs, so
we use _CFURLConnectionSetFrameworkStubs instead.  That works on Intel Macs, too, and I'm reasonably certain
that using it everywhere won't break anything, so as a step towards rdar://problem/15588174 which should allow
us to use asynchronous messages and no more globalNetworkProcess pointer, let's stop using DYLD_INTERPOSE.

* Shared/mac/SecItemShim.cpp:
(WebKit::initializeSecItemShim):

Canonical link: https://commits.webkit.org/231476@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Alex Christensen authored and webkit-commit-queue committed Nov 11, 2020
1 parent b291af8 commit 5272155
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
18 changes: 18 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,21 @@
2020-11-11 Alex Christensen <achristensen@webkit.org>

Use _CFURLConnectionSetFrameworkStubs instead of DYLD_INTERPOSE on Intel Macs
https://bugs.webkit.org/show_bug.cgi?id=218810

Reviewed by Geoffrey Garen.

A long, long time ago, we realized that CFNetwork was looking in the keychain for persistent credentials,
and in order to make the network process get credentials as the UI process, we introduced SecItemShim which
used DYLD_INTERPOSE to intercept the calls to the security framework and synchronously message the UI process
for those calls. Over the last 6 years we have realized that doesn't work on iOS or Apple silicon Macs, so
we use _CFURLConnectionSetFrameworkStubs instead. That works on Intel Macs, too, and I'm reasonably certain
that using it everywhere won't break anything, so as a step towards rdar://problem/15588174 which should allow
us to use asynchronous messages and no more globalNetworkProcess pointer, let's stop using DYLD_INTERPOSE.

* Shared/mac/SecItemShim.cpp:
(WebKit::initializeSecItemShim):

2020-11-11 Alex Christensen <achristensen@webkit.org>

Don't look in keychain for SecKeyRef after deserializing SecIdentityRef
Expand Down
14 changes: 0 additions & 14 deletions Source/WebKit/Shared/mac/SecItemShim.cpp
Expand Up @@ -143,7 +143,6 @@ void initializeSecItemShim(NetworkProcess& process)
{
globalNetworkProcess() = makeWeakPtr(process);

#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && !CPU(X86_64))
struct _CFNFrameworksStubs stubs = {
.version = 0,
.SecItem_stub_CopyMatching = webSecItemCopyMatching,
Expand All @@ -153,19 +152,6 @@ void initializeSecItemShim(NetworkProcess& process)
};

_CFURLConnectionSetFrameworkStubs(&stubs);
#endif

#if PLATFORM(MAC) && CPU(X86_64)
const SecItemShimCallbacks callbacks = {
webSecItemCopyMatching,
webSecItemAdd,
webSecItemUpdate,
webSecItemDelete
};

SecItemShimInitializeFunc func = reinterpret_cast<SecItemShimInitializeFunc>(dlsym(RTLD_DEFAULT, "WebKitSecItemShimInitialize"));
func(callbacks);
#endif
}

} // namespace WebKit
Expand Down

0 comments on commit 5272155

Please sign in to comment.