Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 0/4] ALSA: compress: fix buffer handling and state validation
@ 2026-10-19 14:45 Peter Ujfalusi
  2026-10-19 14:45 ` [PATCH v2 1/4] ALSA: compress: fix buffer leak on failed SET_PARAMS Peter Ujfalusi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2026-10-19 14:45 UTC (permalink / raw)
  To: vkoul, perex, tiwai; +Cc: pierre-louis.bossart, linux-sound, stable

Hi,

Changes since v1:
- patch 1: do not free the old buffer in snd_compr_allocate_buffer().
  SET_PARAMS can only be repeated in OPEN state after ops->set_params()
  has failed, so release the framework-owned buffer on that error path
  instead. The buffer is allocated once per successful SET_PARAMS and is
  never replaced (Vinod, Takashi)
- patch 2: reworded the commit message: the buffer is set up once and the
  next_track path does not re-allocate it. The geometry check is kept
  because ops->set_params() would otherwise receive buffer parameters
  that do not match the buffer in use. tinycompress always passes the
  open-time fragment_size/fragments on next_track, so existing users are
  not affected (Vinod)
- patches 3 and 4: added Acked-by from Vinod

The compress offload core has several edge cases in buffer management
and state validation.

A SET_PARAMS that the driver rejects leaves the framework-owned buffer
allocated while the stream stays in the OPEN state, so a following
SET_PARAMS overwrites the pointer and leaks the buffer. During gapless
playback, SET_PARAMS can also change the buffer geometry while the byte
counters still refer to the current buffer. Separately, SET_METADATA can
reach the driver before SET_PARAMS, and the origin_seqno task lookup can
restart a task that is still ACTIVE.

Address these cases by:
- releasing the framework-owned buffer when ops->set_params() fails, so
  the buffer is allocated once per successful SET_PARAMS;
- not re-allocating the buffer on the gapless next_track path and
  rejecting a buffer geometry change there;
- rejecting SET_METADATA while the stream is OPEN; and
- allowing origin_seqno to reuse IDLE or FINISHED tasks, but not ACTIVE
  ones.

Regards,
Peter
---
Peter Ujfalusi (4):
  ALSA: compress: fix buffer leak on failed SET_PARAMS
  ALSA: compress: reject buffer geometry change on gapless next_track
  ALSA: compress: add missing OPEN-state gate to SET_METADATA
  ALSA: compress: reject restarting an ACTIVE task via origin_seqno

 sound/core/compress_offload.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

-- 
2.56.0


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

end of thread, other threads:[~2026-10-20  8:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 14:45 [PATCH v2 0/4] ALSA: compress: fix buffer handling and state validation Peter Ujfalusi
2026-10-19 14:45 ` [PATCH v2 1/4] ALSA: compress: fix buffer leak on failed SET_PARAMS Peter Ujfalusi
2026-10-19 14:45 ` [PATCH v2 2/4] ALSA: compress: reject buffer geometry change on gapless next_track Peter Ujfalusi
2026-10-19 14:45 ` [PATCH v2 3/4] ALSA: compress: add missing OPEN-state gate to SET_METADATA Peter Ujfalusi
2026-10-19 14:45 ` [PATCH v2 4/4] ALSA: compress: reject restarting an ACTIVE task via origin_seqno Peter Ujfalusi
2026-10-20  8:48 ` [PATCH v2 0/4] ALSA: compress: fix buffer handling and state validation Takashi Iwai

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