Bug 234986 - WebsiteDataStore.cpp uses switch statements for WebKit::ProcessAccessType enum that fall through ASSERT_NOT_REACHED()
Summary: WebsiteDataStore.cpp uses switch statements for WebKit::ProcessAccessType enu...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on: 234932
Blocks:
  Show dependency treegraph
 
Reported: 2022-01-07 14:23 PST by David Kilzer (:ddkilzer)
Modified: 2022-01-19 13:31 PST (History)
6 users (show)

See Also:


Attachments
Patch (7.79 KB, patch)
2022-01-19 09:53 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (7.96 KB, patch)
2022-01-19 10:42 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2022-01-07 14:23:51 PST
WebsiteDataStore.cpp uses switch statements for WebKit::ProcessAccessType enum that fall through ASSERT_NOT_REACHED().

In these cases, it's not clear whether the statement after the switch() statement should be run for every WebKit::ProcessAccessType enum value.

    auto webProcessAccessType = computeWebProcessAccessTypeForDataFetch(dataTypes, !isPersistent());
    if (webProcessAccessType != ProcessAccessType::None) {
        for (auto& process : processes()) {
            switch (webProcessAccessType) {
            case ProcessAccessType::OnlyIfLaunched:
                if (process.state() != WebProcessProxy::State::Running)
                    continue;
                break;

            case ProcessAccessType::Launch:
                // FIXME: Handle this.
                ASSERT_NOT_REACHED();
                break;

            case ProcessAccessType::None:
                ASSERT_NOT_REACHED();
            }

            process.fetchWebsiteData(m_sessionID, dataTypes, [callbackAggregator](WebsiteData websiteData) {
                callbackAggregator->addWebsiteData(WTFMove(websiteData));
            });
        }
    }

See Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp.

There are seven places where this occurs (in four switch statements):

ERROR: Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:482:  ASSERT_NOT_REACHED() statement fallthrough may result in unexpected code execution.  [security/assertion_fallthrough] [4]
ERROR: Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:486:  ASSERT_NOT_REACHED() statement fallthrough may result in unexpected code execution.  [security/assertion_fallthrough] [4]
ERROR: Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:664:  ASSERT_NOT_REACHED() statement fallthrough may result in unexpected code execution.  [security/assertion_fallthrough] [4]
ERROR: Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:668:  ASSERT_NOT_REACHED() statement fallthrough may result in unexpected code execution.  [security/assertion_fallthrough] [4]
ERROR: Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:751:  ASSERT_NOT_REACHED() statement fallthrough may result in unexpected code execution.  [security/assertion_fallthrough] [4]
ERROR: Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:783:  ASSERT_NOT_REACHED() statement fallthrough may result in unexpected code execution.  [security/assertion_fallthrough] [4]
ERROR: Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:787:  ASSERT_NOT_REACHED() statement fallthrough may result in unexpected code execution.  [security/assertion_fallthrough] [4]
Comment 1 Radar WebKit Bug Importer 2022-01-07 14:24:59 PST
<rdar://problem/87272534>
Comment 2 Chris Dumez 2022-01-19 09:53:20 PST
Created attachment 449490 [details]
Patch
Comment 3 Darin Adler 2022-01-19 09:59:04 PST
Comment on attachment 449490 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=449490&action=review

> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:550
>      UNUSED_PARAM(isNonPersistentStore);

I suggest we omit the argument name instead of using UNUSED_PARAM. Could even put it in comments. The reason I always try to avoid UNUSED_PARAM is that it doesn’t even prevent the code from using the parameter.

But also, why are we even passing this boolean argument to this function? Let’s just omit it.
Comment 4 Chris Dumez 2022-01-19 10:42:28 PST
Created attachment 449493 [details]
Patch
Comment 5 EWS 2022-01-19 13:31:15 PST
Committed r288238 (246192@main): <https://commits.webkit.org/246192@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449493 [details].