From 106710c5464f546f49b1a156c81005f3ba8cac183016738f9b13b0309df73365 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 15 Feb 2024 13:06:31 +0000 Subject: [PATCH] Accepting request 1146319 from home:seil0:branches:multimedia:libs - Add cherry-picks to fix UCM crashes * pulseaudio-replace-port-device-UCM-context-assertion-with-an-error.patch * pulseaudio-check-UCM-verb-before-working-with-device-status.patch OBS-URL: https://build.opensuse.org/request/show/1146319 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/pulseaudio?expand=0&rev=267 --- ...rb-before-working-with-device-status.patch | 95 +++++++++++++++++++ ...-UCM-context-assertion-with-an-error.patch | 64 +++++++++++++ pulseaudio.changes | 7 ++ pulseaudio.spec | 4 + 4 files changed, 170 insertions(+) create mode 100644 pulseaudio-check-UCM-verb-before-working-with-device-status.patch create mode 100644 pulseaudio-replace-port-device-UCM-context-assertion-with-an-error.patch diff --git a/pulseaudio-check-UCM-verb-before-working-with-device-status.patch b/pulseaudio-check-UCM-verb-before-working-with-device-status.patch new file mode 100644 index 0000000..42f3c34 --- /dev/null +++ b/pulseaudio-check-UCM-verb-before-working-with-device-status.patch @@ -0,0 +1,95 @@ +From f5cacd94abcc47003bd88ad7ca1450de649ffb15 Mon Sep 17 00:00:00 2001 +From: Alper Nebi Yasak +Date: Thu, 30 Nov 2023 20:17:22 +0300 +Subject: [PATCH] alsa-ucm: Check UCM verb before working with device status + +Some versions of the ALSA libraries run into a segmentation fault when +we query a UCM device/modifier status without first setting a UCM verb. +It's not a reasonable thing to do anyway, so check for this case and +return an error. Also do the check in other helpers. + +Signed-off-by: Alper Nebi Yasak +Part-of: +--- + src/modules/alsa/alsa-ucm.c | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c +index bb9438f79..7f5136249 100644 +--- a/src/modules/alsa/alsa-ucm.c ++++ b/src/modules/alsa/alsa-ucm.c +@@ -624,6 +624,11 @@ static long ucm_device_status(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *dev) + char *devstatus; + long status = 0; + ++ if (!ucm->active_verb) { ++ pa_log_error("Failed to get status for UCM device %s: no UCM verb set", dev_name); ++ return -1; ++ } ++ + devstatus = pa_sprintf_malloc("_devstatus/%s", dev_name); + if (snd_use_case_geti(ucm->ucm_mgr, devstatus, &status) < 0) { + pa_log_debug("Failed to get status for UCM device %s", dev_name); +@@ -637,6 +642,11 @@ static long ucm_device_status(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *dev) + static int ucm_device_disable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *dev) { + const char *dev_name = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME); + ++ if (!ucm->active_verb) { ++ pa_log_error("Failed to disable UCM device %s: no UCM verb set", dev_name); ++ return -1; ++ } ++ + /* If any of dev's conflicting devices is enabled, trying to disable + * dev gives an error despite the fact that it's already disabled. + * Check that dev is enabled to avoid this error. */ +@@ -657,6 +667,11 @@ static int ucm_device_disable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *dev) + static int ucm_device_enable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *dev) { + const char *dev_name = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME); + ++ if (!ucm->active_verb) { ++ pa_log_error("Failed to enable UCM device %s: no UCM verb set", dev_name); ++ return -1; ++ } ++ + /* We don't need to enable devices that are already enabled */ + if (ucm_device_status(ucm, dev) > 0) { + pa_log_debug("UCM device %s is already enabled", dev_name); +@@ -707,6 +722,11 @@ static long ucm_modifier_status(pa_alsa_ucm_config *ucm, pa_alsa_ucm_modifier *m + char *modstatus; + long status = 0; + ++ if (!ucm->active_verb) { ++ pa_log_error("Failed to get status for UCM modifier %s: no UCM verb set", mod_name); ++ return -1; ++ } ++ + modstatus = pa_sprintf_malloc("_modstatus/%s", mod_name); + if (snd_use_case_geti(ucm->ucm_mgr, modstatus, &status) < 0) { + pa_log_debug("Failed to get status for UCM modifier %s", mod_name); +@@ -720,6 +740,11 @@ static long ucm_modifier_status(pa_alsa_ucm_config *ucm, pa_alsa_ucm_modifier *m + static int ucm_modifier_disable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_modifier *mod) { + const char *mod_name = pa_proplist_gets(mod->proplist, PA_ALSA_PROP_UCM_NAME); + ++ if (!ucm->active_verb) { ++ pa_log_error("Failed to disable UCM modifier %s: no UCM verb set", mod_name); ++ return -1; ++ } ++ + /* We don't need to disable modifiers that are already disabled */ + if (ucm_modifier_status(ucm, mod) == 0) { + pa_log_debug("UCM modifier %s is already disabled", mod_name); +@@ -738,6 +763,11 @@ static int ucm_modifier_disable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_modifier *m + static int ucm_modifier_enable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_modifier *mod) { + const char *mod_name = pa_proplist_gets(mod->proplist, PA_ALSA_PROP_UCM_NAME); + ++ if (!ucm->active_verb) { ++ pa_log_error("Failed to disable UCM modifier %s: no UCM verb set", mod_name); ++ return -1; ++ } ++ + /* We don't need to enable modifiers that are already enabled */ + if (ucm_modifier_status(ucm, mod) > 0) { + pa_log_debug("UCM modifier %s is already enabled", mod_name); +-- +GitLab + diff --git a/pulseaudio-replace-port-device-UCM-context-assertion-with-an-error.patch b/pulseaudio-replace-port-device-UCM-context-assertion-with-an-error.patch new file mode 100644 index 0000000..e75f324 --- /dev/null +++ b/pulseaudio-replace-port-device-UCM-context-assertion-with-an-error.patch @@ -0,0 +1,64 @@ +From ed3d4f0837f670e5e5afb1afa5bcfc8ff05d3407 Mon Sep 17 00:00:00 2001 +From: Alper Nebi Yasak +Date: Fri, 1 Dec 2023 13:28:05 +0300 +Subject: [PATCH] alsa-ucm: Replace port device UCM context assertion with an + error + +The pa_alsa_ucm_set_port() function is passed both a mapping context and +a device port, and both of these refer to their respective UCM device. +While switching over to having one port per mapping per UCM device, I +expected both of these to be the same device struct, so added an assert +checking so. + +This assertion gets triggered when we have multiple UCM verbs declaring +the same UCM device name. The root cause here is that the ports' UCM +device references are set once while creating the ports for the card, so +they happen to be those of a specific verb and may not match those from +a different UCM verb's profiles' mappings. + +Solving the root cause necessitates a larger refactor. What we actually +assume here is that name of the UCM device is same for both the port and +the UCM context, which ends up always true in practice. For now, replace +the assert with a check and error. + +Signed-off-by: Alper Nebi Yasak +Part-of: +--- + src/modules/alsa/alsa-ucm.c | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c +index 7f5136249..018c01739 100644 +--- a/src/modules/alsa/alsa-ucm.c ++++ b/src/modules/alsa/alsa-ucm.c +@@ -1581,6 +1581,7 @@ int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *p + pa_alsa_ucm_config *ucm; + pa_alsa_ucm_device *dev; + pa_alsa_ucm_port_data *data; ++ const char *dev_name, *ucm_dev_name; + + pa_assert(context && context->ucm); + +@@ -1588,8 +1589,17 @@ int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *p + pa_assert(ucm->ucm_mgr); + + data = PA_DEVICE_PORT_DATA(port); +- dev = context->ucm_device; +- pa_assert(dev == data->device); ++ dev = data->device; ++ pa_assert(dev); ++ ++ if (context->ucm_device) { ++ dev_name = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME); ++ ucm_dev_name = pa_proplist_gets(context->ucm_device->proplist, PA_ALSA_PROP_UCM_NAME); ++ if (!pa_streq(dev_name, ucm_dev_name)) { ++ pa_log_error("Failed to set port %s with wrong UCM context: %s", dev_name, ucm_dev_name); ++ return -1; ++ } ++ } + + return ucm_device_enable(ucm, dev); + } +-- +GitLab + diff --git a/pulseaudio.changes b/pulseaudio.changes index 908ab61..68ec82c 100644 --- a/pulseaudio.changes +++ b/pulseaudio.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Feb 13 07:21:51 UTC 2024 - Jannik Seiler + +- Add cherry-picks to fix UCM crashes + * pulseaudio-replace-port-device-UCM-context-assertion-with-an-error.patch + * pulseaudio-check-UCM-verb-before-working-with-device-status.patch + ------------------------------------------------------------------- Thu Feb 8 11:24:48 UTC 2024 - Takashi Iwai diff --git a/pulseaudio.spec b/pulseaudio.spec index 150dbac..575c796 100644 --- a/pulseaudio.spec +++ b/pulseaudio.spec @@ -54,6 +54,8 @@ Patch5: qpaeq-shebang.patch Patch6: pulseaudio-old-systemd-workaround.patch # PATCH-FIX-OPENSUSE Workaround for suse-module-tools directory Patch7: pulseaudio-dump-module-Ignore-invalid-module-init-tools.patch +Patch8: pulseaudio-replace-port-device-UCM-context-assertion-with-an-error.patch +Patch9: pulseaudio-check-UCM-verb-before-working-with-device-status.patch BuildRequires: alsa-devel >= 1.0.19 BuildRequires: bluez-devel >= 5 BuildRequires: fdupes @@ -330,6 +332,8 @@ System user for PulseAudio %patch -P6 -p1 %endif %patch -P7 -p1 +%patch -P8 -p1 +%patch -P9 -p1 %build %meson \