qemu/crypto
Peter Maydell 87e012f29f crypto/tlscredspsk: Free username on finalize
When the creds->username property is set we allocate memory
for it in qcrypto_tls_creds_psk_prop_set_username(), but
we never free this when the QCryptoTLSCredsPSK is destroyed.
Free the memory in finalize.

This fixes a LeakSanitizer complaint in migration-test:

$ (cd build/asan; ASAN_OPTIONS="fast_unwind_on_malloc=0" QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test --tap -k -p /x86_64/migration/precopy/unix/tls/psk)

=================================================================
==3867512==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 5 byte(s) in 1 object(s) allocated from:
    #0 0x5624e5c99dee in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-x86_64+0x218edee) (BuildId: a9e623fa1009a9435c0142c037cd7b8c1ad04ce3)
    #1 0x7fb199ae9738 in g_malloc debian/build/deb/../../../glib/gmem.c:128:13
    #2 0x7fb199afe583 in g_strdup debian/build/deb/../../../glib/gstrfuncs.c:361:17
    #3 0x5624e82ea919 in qcrypto_tls_creds_psk_prop_set_username /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../crypto/tlscredspsk.c:255:23
    #4 0x5624e812c6b5 in property_set_str /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object.c:2277:5
    #5 0x5624e8125ce5 in object_property_set /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object.c:1463:5
    #6 0x5624e8136e7c in object_set_properties_from_qdict /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object_interfaces.c:55:14
    #7 0x5624e81372d2 in user_creatable_add_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object_interfaces.c:112:5
    #8 0x5624e8137964 in user_creatable_add_qapi /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object_interfaces.c:157:11
    #9 0x5624e891ba3c in qmp_object_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/qom-qmp-cmds.c:227:5
    #10 0x5624e8af9118 in qmp_marshal_object_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qapi/qapi-commands-qom.c:337:5
    #11 0x5624e8bd1d49 in do_qmp_dispatch_bh /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qapi/qmp-dispatch.c:128:5
    #12 0x5624e8cb2531 in aio_bh_call /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/async.c:171:5
    #13 0x5624e8cb340c in aio_bh_poll /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/async.c:218:13
    #14 0x5624e8c0be98 in aio_dispatch /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/aio-posix.c:423:5
    #15 0x5624e8cba3ce in aio_ctx_dispatch /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/async.c:360:5
    #16 0x7fb199ae0d3a in g_main_dispatch debian/build/deb/../../../glib/gmain.c:3419:28
    #17 0x7fb199ae0d3a in g_main_context_dispatch debian/build/deb/../../../glib/gmain.c:4137:7
    #18 0x5624e8cbe1d9 in glib_pollfds_poll /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/main-loop.c:287:9
    #19 0x5624e8cbcb13 in os_host_main_loop_wait /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/main-loop.c:310:5
    #20 0x5624e8cbc6dc in main_loop_wait /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/main-loop.c:589:11
    #21 0x5624e6f3f917 in qemu_main_loop /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../system/runstate.c:801:9
    #22 0x5624e893379c in qemu_default_main /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../system/main.c:37:14
    #23 0x5624e89337e7 in main /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../system/main.c:48:12
    #24 0x7fb197972d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #25 0x7fb197972e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #26 0x5624e5c16fa4 in _start (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-x86_64+0x210bfa4) (BuildId: a9e623fa1009a9435c0142c037cd7b8c1ad04ce3)

SUMMARY: AddressSanitizer: 5 byte(s) leaked in 1 allocation(s).

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20240819145021.38524-1-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2024-08-20 00:49:14 +02:00
..
aes.c
afalg.c
afalgpriv.h
afsplit.c
akcipher-gcrypt.c.inc
akcipher-nettle.c.inc
akcipher.c
akcipherpriv.h
block-luks-priv.h
block-luks.c crypto/block-luks: make range overlap check more readable 2024-07-23 20:30:36 +02:00
block-luks.h
block-qcow.c crypto/block: drop qcrypto_block_open() n_threads argument 2024-06-10 11:05:43 +02:00
block-qcow.h
block.c crypto/block: drop qcrypto_block_open() n_threads argument 2024-06-10 11:05:43 +02:00
blockpriv.h crypto/block: drop qcrypto_block_open() n_threads argument 2024-06-10 11:05:43 +02:00
cipher-afalg.c
cipher-builtin.c.inc
cipher-gcrypt.c.inc crypto: query gcrypt for cipher availability 2024-03-19 20:17:12 +00:00
cipher-gnutls.c.inc crypto/cipher-gnutls.c: Clean up local variable shadowing 2023-09-29 10:07:16 +02:00
cipher-nettle.c.inc crypto: Introduce SM4 symmetric cipher algorithm 2024-02-09 12:47:55 +00:00
cipher.c crypto: Introduce SM4 symmetric cipher algorithm 2024-02-09 12:47:55 +00:00
cipherpriv.h
clmul.c crypto: Add generic 64-bit carry-less multiply routine 2023-09-15 13:57:00 +00:00
der.c
der.h
hash-afalg.c
hash-gcrypt.c
hash-glib.c
hash-gnutls.c
hash-nettle.c
hash.c
hashpriv.h
hmac-gcrypt.c
hmac-glib.c
hmac-gnutls.c
hmac-nettle.c
hmac.c
hmacpriv.h
init.c crypto: drop gnutls debug logging support 2024-07-24 10:39:10 +01:00
ivgen-essiv.c
ivgen-essiv.h
ivgen-plain64.c
ivgen-plain64.h
ivgen-plain.c
ivgen-plain.h
ivgen.c
ivgenpriv.h
meson.build crypto: only include tls-cipher-suites in emulators 2023-10-03 10:29:39 +02:00
pbkdf-gcrypt.c
pbkdf-gnutls.c
pbkdf-nettle.c
pbkdf-stub.c
pbkdf.c
random-gcrypt.c
random-gnutls.c
random-none.c
random-platform.c
rsakey-builtin.c.inc crypto/rsakey-builtin.c.inc: Clean up two error paths 2023-11-07 14:54:56 +00:00
rsakey-nettle.c.inc
rsakey.c
rsakey.h
secret_common.c
secret_keyring.c
secret.c
sm4.c crypto: Add SM4 constant parameter CK 2023-09-11 11:45:55 +10:00
tls-cipher-suites.c crypto: remove shadowed 'ret' variable 2023-09-29 10:07:20 +02:00
tlscreds.c
tlscredsanon.c
tlscredspriv.h
tlscredspsk.c crypto/tlscredspsk: Free username on finalize 2024-08-20 00:49:14 +02:00
tlscredsx509.c
tlssession.c crypto: propagate errors from TLS session I/O callbacks 2024-07-24 10:39:10 +01:00
trace-events
trace.h
xts.c