On Wed, May 03, 2023 at 01:20:37PM +0200, Oswald Buddenhagen wrote:
On Tue, May 02, 2023 at 01:50:07PM +0200, Jaroslav Kysela wrote:
+ * or the next period wake up)
+ */
+ sw_params.silence_threshold = pcm->buffer_size;
+ sw_params.silence_size = silence_size;
so at this point i got the thought "huh, that can exceed the buffer
size. is that ok?" ...
and yes, it is. but ...
the kernel doesn't check silence_threshold, so user space can trigger
the snd_BUG_ON() in snd_pcm_playback_silence(). whoops.
(yes, this predates my patch.)
i'm not sure what the best way to deal with this is. anyway, different
tree, different patch.
actually, that analysis is garbage, because i didn't look at enough
context. :}
the kernel _does_ check the values in snd_pcm_sw_params(), which means
that silence_size exceeding silence_threshold would lead to EINVAL, and
therefore silencing being broken. this will inevitably happen with small
buffer sizes, where the 1/10th sec extension dominates.
as snd_pcm_sw_params() checks the parameters (and snd_pcm_hw_params()
resets the sw params to defaults, so inverse calling order cannot bypass
it), the concern about the crash is invalid. phew.
regards