Skip to content

[C++][FlightRPC] gRPC transport casts Arrow structs to pb::FlightData #55479

Open

Description

@Algunenano

Describe the bug, including details regarding any error messages, version, and platform.

WritePayload() and ReadPayload() in cpp/src/arrow/flight/transport/grpc/serialization_internal.cc pass a FlightPayload or internal::FlightData to gRPC through reinterpret_cast<pb::FlightData*>, and SerializationTraits<pb::FlightData> in customize_grpc.h casts it back. The object is not a pb::FlightData, so this is undefined behavior, and Clang CFI (-fsanitize=cfi-unrelated-cast) rejects it.

We found this in ClickHouse, which embeds Arrow and is enabling Clang CFI in its release builds. It reproduces on upstream main: built with -flto=thin -fwhole-program-vtables -fvisibility=hidden -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-recover=cfi, arrow-flight-test reports one violation per cast site, plus one in gRPC's call_op_set.h on the same object:

serialization_internal.cc:220:25: runtime error: control flow integrity check for type 'arrow::flight::protocol::FlightData' failed during cast to unrelated type

With CFI in trap mode, any Flight RPC that sends or receives FlightData aborts.

Component(s)

C++, FlightRPC

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions