Add assertion to check whether shm files have maximum FileProtection of CompleteUnles...
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 21:24:06 +0000 (21:24 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 21:24:06 +0000 (21:24 +0000)
commit78d83db80577ddaca3b1cf3a518d5f37f26df459
treefb36fcd9b13851ebd0e50e209d648349ddb7f8de
parent881c6b7151bb15c4839151a09ccb5f96ec773d22
Add assertion to check whether shm files have maximum FileProtection of CompleteUnlessOpen
https://bugs.webkit.org/show_bug.cgi?id=197390
<rdar://problem/42685773>

Reviewed by Geoffrey Garen.

Source/WebCore:

We have seen crashes about accessing database files after device is locked. We are suspecting this is because
shm files have wrong data protection class, but shm files should not have Complete class protection when it
is created. It is likely the protection class is changed later. Add an assertion to verify our guess. If the
crash signature changes after this patch, we probably need to change database implementation. If it is not, we
have other problem than data protection.

* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::open):

Source/WebKit:

Move data protection check to WebCore so it can be applied to database files.

* NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
(WebKit::NetworkCache::BlobStorage::add):
* NetworkProcess/cache/NetworkCacheFileSystem.cpp:
(WebKit::NetworkCache::makeSafeToUseMemoryMapForPath): Deleted.
* NetworkProcess/cache/NetworkCacheFileSystem.h:
* NetworkProcess/cache/NetworkCacheFileSystemCocoa.mm: Removed.
* SourcesCocoa.txt:
* UIProcess/API/APIContentRuleListStore.cpp:
(API::openAndMapOrCopyContentRuleList):
(API::compiledToFile):

Source/WTF:

* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::isSafeToUseMemoryMapForPath):
(WTF::FileSystemImpl::makeSafeToUseMemoryMapForPath):
* wtf/FileSystem.h:
* wtf/cocoa/FileSystemCocoa.mm:
(WTF::FileSystemImpl::isSafeToUseMemoryMapForPath):
(WTF::FileSystemImpl::makeSafeToUseMemoryMapForPath):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244921 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/FileSystem.cpp
Source/WTF/wtf/FileSystem.h
Source/WTF/wtf/cocoa/FileSystemCocoa.mm
Source/WebCore/ChangeLog
Source/WebCore/platform/sql/SQLiteDatabase.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp
Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp
Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.h
Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystemCocoa.mm [deleted file]
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp