Don't use mapped cache files in case of Class A/B protected app
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 May 2018 16:15:19 +0000 (16:15 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 May 2018 16:15:19 +0000 (16:15 +0000)
commit67b840515c9883881158ac8e9ef823328773261e
tree76b4e95a38815ae31b59861a05cc93d0e7324b5f
parent965be3352c4528e980b79255ba912c2b1f70088a
Don't use mapped cache files in case of Class A/B protected app
https://bugs.webkit.org/show_bug.cgi?id=185422
<rdar://problem/34001688>

Reviewed by Chris Dumez.

Currently we don't use shared memory maps in these cases. This still leaves us open for crashes
in the network process when the device is locked.

This patch disables use of blob storage (mapped cache files) in apps that use class A/B protection.
Normally we use blobs for resources > 16KB. Since use of shared memory is already disabled,
the only optimization lost for these apps is body data deduplication.

Any existing cache entries with blobs are ignored and deleted. New entries are created with
body data inlined with the metadata.

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::store):
* NetworkProcess/cache/NetworkCache.h:
(WebKit::NetworkCache::Cache::canUseSharedMemoryForBodyData const): Deleted.
* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::initializeShareableResourceHandleFromStorageRecord const):

    Remove the code the prevented use of shared memory in these cases. Non-mapped Data objects
    are never shareable.

(WebKit::NetworkCache::Entry::setNeedsValidation):
* NetworkProcess/cache/NetworkCacheFileSystem.cpp:
(WebKit::NetworkCache::isSafeToUseMemoryMapForPath):
(WebKit::NetworkCache::canUseSharedMemoryForPath): Deleted.
* NetworkProcess/cache/NetworkCacheFileSystem.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::Storage):
(WebKit::NetworkCache::Storage::mayContainBlob const):
(WebKit::NetworkCache::Storage::shouldStoreBodyAsBlob):
(WebKit::NetworkCache::shouldStoreBodyAsBlob): Deleted.
* NetworkProcess/cache/NetworkCacheStorage.h:
(WebKit::NetworkCache::Storage::canUseSharedMemoryForBodyData const): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231484 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit/NetworkProcess/cache/NetworkCache.h
Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.cpp
Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp
Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.h
Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp
Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h