qemu/qapi
Akihiko Odaki b04091393e qapi: Do not cast function pointers
Using -fsanitize=undefined with Clang v18 causes an error if function
pointers are casted:

 qapi/qapi-clone-visitor.c:188:5: runtime error: call to function visit_type_SocketAddress through pointer to incorrect function type 'bool (*)(struct Visitor *, const char *, void **, struct Error **)'
 /tmp/qemu-ubsan/qapi/qapi-visit-sockets.c:487: note: visit_type_SocketAddress defined here
     #0 0x5642aa2f7f3b in qapi_clone qapi/qapi-clone-visitor.c:188:5
     #1 0x5642aa2c8ce5 in qio_channel_socket_listen_async io/channel-socket.c:285:18
     #2 0x5642aa2b8903 in test_io_channel_setup_async tests/unit/test-io-channel-socket.c:116:5
     #3 0x5642aa2b8204 in test_io_channel tests/unit/test-io-channel-socket.c:179:9
     #4 0x5642aa2b8129 in test_io_channel_ipv4 tests/unit/test-io-channel-socket.c:323:5
     ...

It also prevents enabling the strict mode of CFI which is currently
disabled with -fsanitize-cfi-icall-generalize-pointers.

The problematic casts are necessary to pass visit_type_T() and
visit_type_T_members() as callbacks to qapi_clone() and qapi_clone_members(),
respectively. Open-code these two functions to avoid the callbacks, and
thus the type casts.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2346
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240524-xkb-v4-3-2de564e5c859@daynix.com>
[thuth: Improve commit message according to Markus' suggestions]
Signed-off-by: Thomas Huth <thuth@redhat.com>
2024-05-29 12:41:56 +02:00
..
acpi.json qapi: Require descriptions and tagged sections to be indented 2024-02-26 10:43:56 +01:00
audio.json audio/pw: Pipewire->PipeWire case fix for user-visible text 2023-07-17 15:22:56 +04:00
authz.json
block-core.json qapi: blockdev-backup: add discard-source parameter 2024-05-28 15:52:15 +03:00
block-export.json qapi: Move error documentation to new "Errors" sections 2024-03-04 07:12:40 +01:00
block.json qapi: Refill doc comments to conform to current conventions 2024-03-26 06:36:08 +01:00
char.json qapi: Delete useless "Returns" sections 2024-03-04 07:12:40 +01:00
common.json qapi: document PCIe Gen5/Gen6 speeds since 9.0 2024-03-18 04:57:45 -04:00
compat.json qapi: Belatedly update CompatPolicy documentation for unstable 2023-10-19 07:02:29 +02:00
control.json qapi: Drop stray Arguments: line from qmp_capabilities docs 2024-03-26 06:36:08 +01:00
crypto.json qapi: Correct documentation indentation and whitespace 2024-03-26 06:36:08 +01:00
cryptodev.json
cxl.json qapi: Refill doc comments to conform to current conventions 2024-03-26 06:36:08 +01:00
dump.json qapi: Correct documentation indentation and whitespace 2024-03-26 06:36:08 +01:00
ebpf.json qapi: Refill doc comments to conform to current conventions 2024-03-26 06:36:08 +01:00
error.json
introspect.json qapi: Drop redundant documentation of inherited members 2024-02-03 09:19:25 +01:00
job.json blockjob: introduce block-job-change QMP command 2023-10-31 18:20:25 +01:00
machine-common.json CPU topology: extend with s390 specifics 2023-10-20 07:16:53 +02:00
machine-target.json target/s390x: report deprecated-props in cpu-model-expansion reply 2024-05-10 08:34:20 +02:00
machine.json hw/core: Introduce module-id as the topology subindex 2024-04-25 12:48:12 +02:00
meson.build qapi/vfio: Add VFIO migration QAPI event 2024-05-16 16:59:19 +02:00
migration.json migration: Remove non-multifd compression 2024-05-08 09:20:59 -03:00
misc-target.json qapi: Delete useless "Returns" sections 2024-03-04 07:12:40 +01:00
misc.json qapi: Correct documentation indentation and whitespace 2024-03-26 06:36:08 +01:00
net.json qapi: Refill doc comments to conform to current conventions 2024-03-26 06:36:08 +01:00
opts-visitor.c qapi: Inline and remove QERR_INVALID_PARAMETER definition 2024-04-24 09:50:58 +02:00
pci.json qapi: Require descriptions and tagged sections to be indented 2024-02-26 10:43:56 +01:00
pragma.json qapi: document parameters of query-cpu-model-* QAPI commands 2024-03-26 06:36:08 +01:00
qapi-clone-visitor.c qapi: Do not cast function pointers 2024-05-29 12:41:56 +02:00
qapi-dealloc-visitor.c
qapi-forward-visitor.c
qapi-schema.json qapi/vfio: Add VFIO migration QAPI event 2024-05-16 16:59:19 +02:00
qapi-type-helpers.c qapi: New strv_from_str_list() 2024-03-04 07:12:40 +01:00
qapi-util.c qapi: Fix dangling references to docs/devel/qapi-code-gen.txt 2024-01-26 07:04:53 +01:00
qapi-visit-core.c
qdev.json qapi: Delete useless "Returns" sections 2024-03-04 07:12:40 +01:00
qmp-dispatch.c monitor: use aio_co_reschedule_self() 2024-02-07 14:44:21 +01:00
qmp-event.c
qmp-registry.c
qobject-input-visitor.c qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant value) 2024-04-24 09:50:58 +02:00
qobject-output-visitor.c
qom.json i386/sev: Add 'legacy-vm-type' parameter for SEV guest objects 2024-04-23 17:35:25 +02:00
replay.json qapi: Expand a few awkward abbreviations in documentation 2024-03-26 06:36:08 +01:00
rocker.json qapi: Require descriptions and tagged sections to be indented 2024-02-26 10:43:56 +01:00
run-state.json qapi: document leftover members in qapi/run-state.json 2024-03-26 06:36:08 +01:00
sockets.json qapi: Correct documentation indentation and whitespace 2024-03-26 06:36:08 +01:00
stats.json qapi: document leftover members in qapi/stats.json 2024-03-26 06:36:08 +01:00
string-input-visitor.c qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant value) 2024-04-24 09:50:58 +02:00
string-output-visitor.c string-output-visitor: Fix (pseudo) struct handling 2024-01-26 11:16:58 +01:00
tpm.json qapi: Delete useless "Returns" sections 2024-03-04 07:12:40 +01:00
trace-events
trace.h
trace.json qapi: Require descriptions and tagged sections to be indented 2024-02-26 10:43:56 +01:00
transaction.json qapi: Delete useless "Returns" sections 2024-03-04 07:12:40 +01:00
ui.json qapi: document InputMultiTouchType 2024-03-26 06:36:08 +01:00
vfio.json qapi/vfio: Add VFIO migration QAPI event 2024-05-16 16:59:19 +02:00
virtio.json qapi: Refill doc comments to conform to current conventions 2024-03-26 06:36:08 +01:00
yank.json qapi/yank: Tweak @yank's error description for consistency 2024-03-04 07:12:40 +01:00