ALSA: compress: fix buffer handling and state validation
Status from this message: Applied all four patches now. Thanks.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest4 patches 1 replyApplied
- v14 patches 11 repliesSuperseded
Changes in v2 from the cover letter
- 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
Patches in v2 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | ALSA: compress: fix buffer leak on failed SET_PARAMSsound/ | +8 | 0 replies | |
| 2/4 | ALSA: compress: reject buffer geometry change on gapless next_tracksound/ | +13 | 0 replies | |
| 3/4 | ALSA: compress: add missing OPEN-state gate to SET_METADATAsound/ | +3 | 0 replies | |
| 4/4 | ALSA: compress: reject restarting an ACTIVE task via origin_seqnosound/ | +3 | 0 replies |
Reviews trailers per patch
2 of 4 patches have a Reviewed-by or Acked-by.
| Patch | Vinod Koul |
|---|---|
| 1/4 | |
| 2/4 | |
| 3/4 | A-b |
| 4/4 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/4] ALSA: compress: fix buffer handling and state validation
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(-)
Signature · 1 line
2.56.0