[webkit-changes] [WebKit/WebKit] be8e1c: Verify non-serialized members of serialized types ...

Alex Christensen noreply at github.com
Wed Apr 19 08:09:46 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: be8e1cbed551b67d0203aac123801f202143abd4
      https://github.com/WebKit/WebKit/commit/be8e1cbed551b67d0203aac123801f202143abd4
  Author: Alex Christensen <achristensen at apple.com>
  Date:   2023-04-19 (Wed, 19 Apr 2023)

  Changed paths:
    M Source/WebCore/Modules/reporting/DeprecationReportBody.cpp
    M Source/WebCore/Modules/reporting/DeprecationReportBody.h
    M Source/WebCore/Modules/reporting/ReportBody.cpp
    M Source/WebCore/Modules/reporting/ReportBody.h
    M Source/WebCore/Modules/reporting/TestReportBody.cpp
    M Source/WebCore/Modules/reporting/TestReportBody.h
    M Source/WebCore/loader/COEPInheritenceViolationReportBody.cpp
    M Source/WebCore/loader/COEPInheritenceViolationReportBody.h
    M Source/WebCore/loader/CORPViolationReportBody.cpp
    M Source/WebCore/loader/CORPViolationReportBody.h
    M Source/WebCore/page/csp/CSPViolationReportBody.cpp
    M Source/WebCore/page/csp/CSPViolationReportBody.h
    M Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.serialization.in
    M Source/WebKit/Scripts/generate-serializers.py
    M Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.cpp
    M Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.h
    M Source/WebKit/Scripts/webkit/tests/SerializedTypeInfo.cpp
    M Source/WebKit/Scripts/webkit/tests/TestSerializedType.serialization.in
    M Source/WebKit/Shared/SessionState.serialization.in
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in

  Log Message:
  -----------
  Verify non-serialized members of serialized types are not accidentally forgotten
https://bugs.webkit.org/show_bug.cgi?id=255551
rdar://108161764

Reviewed by Chris Dumez.

I introduce the NotSerialized attribute for members that are ... not serialized.

Until we have https://wg21.link/P1240 in the language, we can't iterate the members
at compile time and make sure we got them all.  We already use MembersInCorrectOrder
to make sure we got them in the correct order, but we didn't have a check that we
got them all until now.  This makes a struct that has the same members in the same
order and static_asserts that it has the same size as the actual struct.

To reduce memory use and make this new sizeof trick work, I made ReportBody::type()
a virtual function call instead of using another byte to store the type.

* Source/WebCore/Modules/reporting/DeprecationReportBody.cpp:
(WebCore::DeprecationReportBody::DeprecationReportBody):
* Source/WebCore/Modules/reporting/DeprecationReportBody.h:
* Source/WebCore/Modules/reporting/ReportBody.cpp:
(WebCore::ReportBody::ReportBody): Deleted.
(WebCore::ReportBody::reportBodyType const): Deleted.
* Source/WebCore/Modules/reporting/ReportBody.h:
* Source/WebCore/Modules/reporting/TestReportBody.cpp:
(WebCore::TestReportBody::TestReportBody):
* Source/WebCore/Modules/reporting/TestReportBody.h:
* Source/WebCore/loader/COEPInheritenceViolationReportBody.cpp:
(WebCore::COEPInheritenceViolationReportBody::COEPInheritenceViolationReportBody):
* Source/WebCore/loader/COEPInheritenceViolationReportBody.h:
* Source/WebCore/loader/CORPViolationReportBody.cpp:
(WebCore::CORPViolationReportBody::CORPViolationReportBody):
* Source/WebCore/loader/CORPViolationReportBody.h:
* Source/WebCore/page/csp/CSPViolationReportBody.cpp:
(WebCore::CSPViolationReportBody::CSPViolationReportBody):
* Source/WebCore/page/csp/CSPViolationReportBody.h:
* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.serialization.in:
* Source/WebKit/Scripts/generate-serializers.py:
(SerializedType.__init__):
(SerializedType.has_bit_field):
(SerializedType):
(SerializedType.serialized_members):
(check_type_members):
(check_type_members.is):
(check_type_members.is.is):
(encode_type):
(decode_type):
(construct_type):
(generate_impl):
(generate_serialized_type_info):
* Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.cpp:
(IPC::ArgumentCoder<Namespace::Subnamespace::StructName>::encode):
(IPC::ArgumentCoder<Namespace::EmptyConstructorNullable>::encode):
(IPC::ArgumentCoder<WithoutNamespace>::encode):
(IPC::ArgumentCoder<WithoutNamespaceWithAttributes>::encode):
(IPC::ArgumentCoder<WTF::CreateUsingClass>::encode):
(IPC::ArgumentCoder<NullableSoftLinkedMember>::encode):
(IPC::ArgumentCoder<Namespace::ConditionalCommonClass>::encode):
(IPC::ArgumentCoder<Namesapce::CommonClass>::encode):
(IPC::ArgumentCoder<Namesapce::AnotherCommonClass>::encode):
(IPC::ArgumentCoder<Namesapce::AnotherCommonClass>::decode):
* Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.h:
* Source/WebKit/Scripts/webkit/tests/SerializedTypeInfo.cpp:
* Source/WebKit/Scripts/webkit/tests/TestSerializedType.serialization.in:
* Source/WebKit/Shared/SessionState.serialization.in:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Canonical link: https://commits.webkit.org/263133@main




More information about the webkit-changes mailing list