Changeset 198429 in webkit


Ignore:
Timestamp:
Mar 18, 2016, 10:58:45 AM (10 years ago)
Author:
Antti Koivisto
Message:

Protect against excessive cache traversal
https://bugs.webkit.org/show_bug.cgi?id=155635
rdar://problem/24241008

Reviewed by Darin Adler.

We can't handle unlimited number of parallel cache traversal requests from the client.
We'll run out of dispatch queues and other system resources. CPU will spin.

  • NetworkProcess/cache/NetworkCache.cpp:

(WebKit::NetworkCache::Cache::traverse):

Add limit of maximum 3 traversals. When exceeded return nothing and log an error.

  • NetworkProcess/cache/NetworkCache.h:
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r198393 r198429  
     12016-03-18  Antti Koivisto  <antti@apple.com>
     2
     3        Protect against excessive cache traversal
     4        https://bugs.webkit.org/show_bug.cgi?id=155635
     5        rdar://problem/24241008
     6
     7        Reviewed by Darin Adler.
     8
     9        We can't handle unlimited number of parallel cache traversal requests from the client.
     10        We'll run out of dispatch queues and other system resources. CPU will spin.
     11
     12        * NetworkProcess/cache/NetworkCache.cpp:
     13        (WebKit::NetworkCache::Cache::traverse):
     14
     15            Add limit of maximum 3 traversals. When exceeded return nothing and log an error.
     16
     17        * NetworkProcess/cache/NetworkCache.h:
     18
    1192016-03-18  Darin Adler  <darin@apple.com>
    220
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

    r197879 r198429  
    522522    ASSERT(isEnabled());
    523523
    524     m_storage->traverse(resourceType(), 0, [traverseHandler](const Storage::Record* record, const Storage::RecordInfo& recordInfo) {
     524    // Protect against clients making excessive traversal requests.
     525    const unsigned maximumTraverseCount = 3;
     526    if (m_traverseCount >= maximumTraverseCount) {
     527        WTFLogAlways("Maximum parallel cache traverse count exceeded. Ignoring traversal request.");
     528
     529        RunLoop::main().dispatch([traverseHandler] {
     530            traverseHandler(nullptr);
     531        });
     532        return;
     533    }
     534
     535    ++m_traverseCount;
     536
     537    m_storage->traverse(resourceType(), 0, [this, traverseHandler](const Storage::Record* record, const Storage::RecordInfo& recordInfo) {
    525538        if (!record) {
     539            --m_traverseCount;
    526540            traverseHandler(nullptr);
    527541            return;
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h

    r197180 r198429  
    136136#endif
    137137    std::unique_ptr<Statistics> m_statistics;
     138
     139    unsigned m_traverseCount { 0 };
    138140};
    139141
Note: See TracChangeset for help on using the changeset viewer.