From 8553dc3623520ff6e96e63cb847d74229043a7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 5 Jun 2025 11:59:03 +0200 Subject: [PATCH 1/6] modem-helpers: Don't leak strings when parsing DTMF response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `g_ptr_array_new()` creates an array without a free func, this means we'd leak the strings when the reference count drops to 0. Fixes: 56fe8e7d3 ("modem-helpers: add utility function to split DTMF runs") Signed-off-by: Guido Günther --- src/mm-base-call.c | 1 - src/mm-modem-helpers.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mm-base-call.c b/src/mm-base-call.c index e011c448..bf13bedc 100644 --- a/src/mm-base-call.c +++ b/src/mm-base-call.c @@ -766,7 +766,6 @@ static void send_dtmf_context_free (SendDtmfContext *ctx) { send_dtmf_context_clear_timeout (ctx); - g_ptr_array_foreach (ctx->dtmfs, (GFunc) g_free, NULL); g_ptr_array_free (ctx->dtmfs, TRUE); g_assert (!ctx->saved_error); g_slice_free (SendDtmfContext, ctx); diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 5cbf0836..b3c38feb 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -5895,7 +5895,7 @@ mm_dtmf_split (const gchar *dtmf) const gchar *p = dtmf; GString *cur = NULL; - array = g_ptr_array_new (); + array = g_ptr_array_new_with_free_func (g_free); while (*p) { if (*p == MM_CALL_DTMF_PAUSE_CHAR) { From fc762626ab24f2f3734df1d85ceb18d1f8b3fe12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 5 Jun 2025 12:01:18 +0200 Subject: [PATCH 2/6] modem-helpers: Don't leak `str` when parsing cscb response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We currently overwrite the value without freeing it. Fixes: d8135be6e ("modem-helpers: Add helpers to parse channel lists") Signed-off-by: Guido Günther --- src/mm-modem-helpers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index b3c38feb..c6c75c9c 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -3162,6 +3162,7 @@ mm_3gpp_parse_cscb_response (const char *response, GError **error) goto out; } + g_free (str); str = g_match_info_fetch (match_info, 2); intervals = g_strsplit (str, ",", -1); for (i = 0; intervals[i]; i++) { From 04229ca1467057d8b0db478278773d173d69d149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 5 Jun 2025 10:32:36 +0200 Subject: [PATCH 3/6] modem-helpers: Don't leak in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther --- src/tests/test-modem-helpers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c index 51aedef2..f3cdb438 100644 --- a/src/tests/test-modem-helpers.c +++ b/src/tests/test-modem-helpers.c @@ -4491,7 +4491,7 @@ static void common_test_cscb_response (const gchar *response, TestCscb *expected) { GError *error = NULL; - GArray *result; + g_autoptr(GArray) result = NULL; g_debug ("Testing '%s'", response); result = mm_3gpp_parse_cscb_response (response, &error); @@ -4726,7 +4726,7 @@ test_emergency_numbers (void) for (i = 0; i < G_N_ELEMENTS (emergency_numbers_tests); i++) { GStrv numbers; - GError *error = NULL; + g_autoptr(GError) error = NULL; guint j; g_debug (" testing %s...", emergency_numbers_tests[i].raw); @@ -5138,7 +5138,7 @@ static void test_dtmf_split (gpointer user_data) { DtmfTestData *td = user_data; - GPtrArray *split; + g_autoptr(GPtrArray) split = NULL; guint expected_len; guint i; From aa9447c8337a51013519392ee8b8cbfec9a19186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 5 Jun 2025 10:26:49 +0200 Subject: [PATCH 4/6] tests: Allow to run some tests under asan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther --- src/tests/meson.build | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tests/meson.build b/src/tests/meson.build index a9216c24..18ece913 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (C) 2021 Iñigo Martinez +test_env = environment() +test_env.set('ASAN_OPTIONS', 'fast_unwind_on_malloc=0') + test_units = { 'at-serial-port': libport_dep, 'cbm-part': libhelpers_dep, @@ -47,7 +50,7 @@ foreach test_unit, test_deps: test_units c_args: c_args, ) - test(test_name, exe) + test(test_name, exe, suite: 'daemon', env: test_env) endforeach # base call test @@ -59,7 +62,7 @@ exe = executable( c_args: c_args, ) -test('test-base-call', exe) +test('test-base-call', exe, suite: 'daemon', env: test_env) if get_option('fuzzer') From e97bd6d407216911ae21b3d6498a5a516e188a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 5 Jun 2025 10:55:47 +0200 Subject: [PATCH 5/6] ci: Run daemon tests under ASAN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther --- .gitlab-ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8c52b3b3..bbaff393 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -316,3 +316,18 @@ build-release-builtin: - ninja -C build test - ninja -C build install - ninja -C build uninstall + +build-asan: + stage: build + extends: + - .fdo.distribution-image@ubuntu + - .common_variables + only: + - main + - merge_requests + - tags + - schedules + script: + - *prepare_deps + - meson setup build-asan -Db_sanitize=address -Dwerror=true -Dgtk_doc=false -Dqmi=true -Dqrtr=true -Dmbim=true + - meson test -C build-asan --suite=daemon --timeout-multiplier=5 --print-errorlogs From c21191b59ab71c26593095d8debc9010322b0b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 5 Jun 2025 13:07:37 +0200 Subject: [PATCH 6/6] ci: Use dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows the build job to start without waiting for the dco check Signed-off-by: Guido Günther --- .gitlab-ci.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bbaff393..214debcd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,7 @@ stages: BUILD_QMI: true BUILD_QRTR: true -build container: +build_container: extends: - .fdo.container-build@ubuntu - .common_variables @@ -73,6 +73,7 @@ verify-dco: extends: - .fdo.distribution-image@ubuntu - .common_variables + needs: [] only: - merge_requests script: | @@ -89,6 +90,8 @@ verify-dco: build-no-qmi: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -107,6 +110,8 @@ build-no-qmi: build-qmi-qrtr-no-mbim: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -124,6 +129,8 @@ build-qmi-qrtr-no-mbim: build-qmi-no-qrtr-no-mbim: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -142,6 +149,8 @@ build-qmi-no-qrtr-no-mbim: build-no-qmi-no-mbim: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -162,6 +171,8 @@ build-no-qmi-no-mbim: build-no-qmi-no-mbim-no-tests: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -181,6 +192,8 @@ build-no-qmi-no-mbim-no-tests: build-no-deprecated: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -201,6 +214,8 @@ build-no-deprecated: build-no-suspend-resume: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -217,6 +232,8 @@ build-no-suspend-resume: build-suspend-resume-powerd: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -233,6 +250,8 @@ build-suspend-resume-powerd: build-single-plugins: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -249,6 +268,8 @@ build-single-plugins: build-single-plugins-builtin: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -265,6 +286,8 @@ build-single-plugins-builtin: build-debug: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -283,6 +306,8 @@ build-debug: build-release: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -301,6 +326,8 @@ build-release: build-release-builtin: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables @@ -319,6 +346,8 @@ build-release-builtin: build-asan: stage: build + needs: + - build_container extends: - .fdo.distribution-image@ubuntu - .common_variables