Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 0/3] ASoC: SOF: ipc4-control: fix bytes control restore and replay
@ 2026-11-20  7:00 Ye Weihua
  2026-11-20  7:00 ` [PATCH v2 1/3] ASoC: SOF: ipc4-control: Fix out-of-bounds backup restore in bytes ext put Ye Weihua
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ye Weihua @ 2026-11-20  7:00 UTC (permalink / raw)
  To: Liam Girdwood, Peter Ujfalusi, Bard Liao, Daniel Baluta,
	Kai Vehmanen, Pierre-Louis Bossart, Vijendar Mukunda, Mark Brown,
	Jaroslav Kysela, Takashi Iwai
  Cc: sound-open-firmware, linux-sound, stable, Ye Weihua

sof_ipc4_bytes_ext_put() backed up the last known good bytes control data
with the current payload size (scontrol->size), which can be smaller than
the allocation and can grow beyond the backup after a later successful
update. Restoring that backup therefore read past the end of the
kmemdup() buffer. The backup also did not cover the ABI header and
payload for controls loaded without initial data, and scontrol->size was
not rolled back when copy_from_user() failed.

Patch 1 backs up and restores the whole allocated control data
(sizeof(*cdata) + scontrol->max_size), matching the IPC3 implementation,
and recomputes scontrol->size from the restored ABI header and payload.
It also updates scontrol->size only after the firmware accepted the
update, so a successful restore replay cannot overwrite the restored
length with the rejected one.

The backup is also leaked when a control is released while the backup is
still present, so patch 2 frees it in both control release paths. The
replay after a rejected update used the message built from the rejected
data; patch 3 rebuilds that message from the restored data before
replaying it, for both regular bytes controls and
SOF_IPC4_BYTES_CONTROL_PARAM_ID controls, whose payload lives in a
separate buffer that also has to be rebuilt.

Changes in v2:
- Back up and restore the whole allocation instead of adding an
  old_ipc_control_data_size field, so sof-audio.h is no longer touched
  and the u32/size_t mismatch is gone.
- Recompute scontrol->size from the restored ABI header and payload on
  every restore, including the copy_from_user() failure path.
- Move the replay fix into its own patch and rebuild the message from the
  restored data, including the SOF_IPC4_BYTES_CONTROL_PARAM_ID path that
  was previously left as a follow-up.
- Free the backup in both sof_control_unload() and sof_widget_unload().

Link: https://lore.kernel.org/all/20261119121446.124833-1-yeweihua4@huawei.com/

Ye Weihua (3):
  ASoC: SOF: ipc4-control: Fix out-of-bounds backup restore in bytes ext
    put
  ASoC: SOF: topology: Free bytes control backup on unload
  ASoC: SOF: ipc4-control: Rebuild replay message after restoring data

 sound/soc/sof/ipc4-control.c | 95 +++++++++++++++++++++++++++++-------
 sound/soc/sof/topology.c     |  2 +
 2 files changed, 79 insertions(+), 18 deletions(-)


base-commit: 7cfbf79c66c63e807ea452abf0546e6f6d6833a6
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-20  7:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  7:00 [PATCH v2 0/3] ASoC: SOF: ipc4-control: fix bytes control restore and replay Ye Weihua
2026-11-20  7:00 ` [PATCH v2 1/3] ASoC: SOF: ipc4-control: Fix out-of-bounds backup restore in bytes ext put Ye Weihua
2026-11-20  7:00 ` [PATCH v2 2/3] ASoC: SOF: topology: Free bytes control backup on unload Ye Weihua
2026-11-20  7:00 ` [PATCH v2 3/3] ASoC: SOF: ipc4-control: Rebuild replay message after restoring data Ye Weihua
2026-11-20  7:42   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox