* [PATCH] ALSA: pcm: derive the audio timestamp for the DEFAULT type
@ 2026-11-30 7:41 Hao Ge
2026-11-30 7:56 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Hao Ge @ 2026-11-30 7:41 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai; +Cc: linux-sound, linux-kernel, Hao Ge, stable
snd_pcm_update_hw_ptr0() calls ->get_time_info() only when
audio_tstamp_config.type_requested is not DEFAULT, while
update_audio_tstamp() derives the timestamp from the buffer position
only when audio_tstamp_report.actual_type is DEFAULT. The two
conditions do not line up for a stream that requests the DEFAULT
type. The callback is never called for such a stream, so actual_type
stays at SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT, the zero value a
kzalloc'ed runtime starts with, and update_audio_tstamp() reads the
local audio_tstamp that was never written. This path never reaches a
driver, so it cannot be fixed driver-side.
BUG: KMSAN: uninit-value in update_audio_tstamp+0x728/0x880 [snd_pcm]
update_audio_tstamp+0x728/0x880 [snd_pcm]
snd_pcm_update_hw_ptr0+0x189c/0x1c50 [snd_pcm]
snd_pcm_delay+0x258/0x890 [snd_pcm]
snd_pcm_common_ioctl+0x2ef/0xbc0 [snd_pcm]
snd_pcm_ioctl+0x72/0xd0 [snd_pcm]
__se_sys_ioctl+0x1be/0x340
do_syscall_64+0x138/0x4b0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Local variable audio_tstamp created at:
snd_pcm_update_hw_ptr0+0x9f/0x1c50 [snd_pcm]
The reports come from a PipeWire stream querying
SNDRV_PCM_IOCTL_DELAY and SNDRV_PCM_IOCTL_STATUS64, and from the
period elapsed interrupt.
Also take the requested type into account in
update_audio_tstamp(), and derive the timestamp from the buffer
position when the caller asked for DEFAULT, which is what the type
means.
Fixes: 4eeaaeaea1ce ("ALSA: core: add hooks for audio timestamps")
Cc: stable@vger.kernel.org
Signed-off-by: Hao Ge <hao.ge@linux.dev>
---
sound/core/pcm_lib.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index bb16738bb591..a243a91f9489 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -245,6 +245,8 @@ static void update_audio_tstamp(struct snd_pcm_substream *substream,
return;
if (!(substream->ops->get_time_info) ||
+ (runtime->audio_tstamp_config.type_requested ==
+ SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT) ||
(runtime->audio_tstamp_report.actual_type ==
SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) {
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: pcm: derive the audio timestamp for the DEFAULT type
2026-11-30 7:41 [PATCH] ALSA: pcm: derive the audio timestamp for the DEFAULT type Hao Ge
@ 2026-11-30 7:56 ` sashiko-bot
2026-11-30 8:16 ` Hao Ge
0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-11-30 7:56 UTC (permalink / raw)
To: Hao Ge; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ALSA: pcm: Fixes trailer cites 4eeaaeaea1ce instead of
3179f6200188
--
commit 22b28b123f8965cc05b0606befd025969a4f6aef
Author: Hao Ge <hao.ge@linux.dev>
> ALSA: pcm: derive the audio timestamp for the DEFAULT type
>
> snd_pcm_update_hw_ptr0() calls ->get_time_info() only when
> audio_tstamp_config.type_requested is not DEFAULT, while
> update_audio_tstamp() derives the timestamp from the buffer position
> only when audio_tstamp_report.actual_type is DEFAULT. The two
> conditions do not line up for a stream that requests the DEFAULT
> type. The callback is never called for such a stream, so actual_type
> stays at SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT, the zero value a
> kzalloc'ed runtime starts with, and update_audio_tstamp() reads the
> local audio_tstamp that was never written. This path never reaches a
> driver, so it cannot be fixed driver-side.
>
> BUG: KMSAN: uninit-value in update_audio_tstamp+0x728/0x880 [snd_pcm]
> update_audio_tstamp+0x728/0x880 [snd_pcm]
> snd_pcm_update_hw_ptr0+0x189c/0x1c50 [snd_pcm]
> snd_pcm_delay+0x258/0x890 [snd_pcm]
> snd_pcm_common_ioctl+0x2ef/0xbc0 [snd_pcm]
> snd_pcm_ioctl+0x72/0xd0 [snd_pcm]
> __se_sys_ioctl+0x1be/0x340
> do_syscall_64+0x138/0x4b0
> entry_SYSCALL_64_after_hwframe+0x76/0x7e
> Local variable audio_tstamp created at:
> snd_pcm_update_hw_ptr0+0x9f/0x1c50 [snd_pcm]
>
> The reports come from a PipeWire stream querying
> SNDRV_PCM_IOCTL_DELAY and SNDRV_PCM_IOCTL_STATUS64, and from the
> period elapsed interrupt.
>
> Also take the requested type into account in
> update_audio_tstamp(), and derive the timestamp from the buffer
> position when the caller asked for DEFAULT, which is what the type
> means.
>
> Fixes: 4eeaaeaea1ce ("ALSA: core: add hooks for audio timestamps")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hao Ge <hao.ge@linux.dev>
[Severity: Low]
Should the Fixes tag reference 3179f6200188 ("ALSA: core: add
.get_time_info") instead of 4eeaaeaea1ce ("ALSA: core: add hooks for
audio timestamps")?
Commit 4eeaaeaea1ce ("ALSA: core: add hooks for audio timestamps") only
added the legacy .wall_clock hook. Commit 3179f6200188 ("ALSA: core: add
.get_time_info") introduced update_audio_tstamp(), the type_requested !=
SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT guard around ->get_time_info(), and
the mismatched actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT check.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130074144.120573-1-hao.ge@linux.dev?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: pcm: derive the audio timestamp for the DEFAULT type
2026-11-30 7:56 ` sashiko-bot
@ 2026-11-30 8:16 ` Hao Ge
0 siblings, 0 replies; 3+ messages in thread
From: Hao Ge @ 2026-11-30 8:16 UTC (permalink / raw)
To: Takashi Iwai, Jaroslav Kysela; +Cc: linux-sound, sashiko-reviews
On 2026/11/30 15:56, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] ALSA: pcm: Fixes trailer cites 4eeaaeaea1ce instead of
> 3179f6200188
> --
>
> commit 22b28b123f8965cc05b0606befd025969a4f6aef
> Author: Hao Ge <hao.ge@linux.dev>
>
>> ALSA: pcm: derive the audio timestamp for the DEFAULT type
>>
>> snd_pcm_update_hw_ptr0() calls ->get_time_info() only when
>> audio_tstamp_config.type_requested is not DEFAULT, while
>> update_audio_tstamp() derives the timestamp from the buffer position
>> only when audio_tstamp_report.actual_type is DEFAULT. The two
>> conditions do not line up for a stream that requests the DEFAULT
>> type. The callback is never called for such a stream, so actual_type
>> stays at SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT, the zero value a
>> kzalloc'ed runtime starts with, and update_audio_tstamp() reads the
>> local audio_tstamp that was never written. This path never reaches a
>> driver, so it cannot be fixed driver-side.
>>
>> BUG: KMSAN: uninit-value in update_audio_tstamp+0x728/0x880 [snd_pcm]
>> update_audio_tstamp+0x728/0x880 [snd_pcm]
>> snd_pcm_update_hw_ptr0+0x189c/0x1c50 [snd_pcm]
>> snd_pcm_delay+0x258/0x890 [snd_pcm]
>> snd_pcm_common_ioctl+0x2ef/0xbc0 [snd_pcm]
>> snd_pcm_ioctl+0x72/0xd0 [snd_pcm]
>> __se_sys_ioctl+0x1be/0x340
>> do_syscall_64+0x138/0x4b0
>> entry_SYSCALL_64_after_hwframe+0x76/0x7e
>> Local variable audio_tstamp created at:
>> snd_pcm_update_hw_ptr0+0x9f/0x1c50 [snd_pcm]
>>
>> The reports come from a PipeWire stream querying
>> SNDRV_PCM_IOCTL_DELAY and SNDRV_PCM_IOCTL_STATUS64, and from the
>> period elapsed interrupt.
>>
>> Also take the requested type into account in
>> update_audio_tstamp(), and derive the timestamp from the buffer
>> position when the caller asked for DEFAULT, which is what the type
>> means.
>>
>> Fixes: 4eeaaeaea1ce ("ALSA: core: add hooks for audio timestamps")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Hao Ge <hao.ge@linux.dev>
>
> [Severity: Low]
> Should the Fixes tag reference 3179f6200188 ("ALSA: core: add
> .get_time_info") instead of 4eeaaeaea1ce ("ALSA: core: add hooks for
> audio timestamps")?
>
> Commit 4eeaaeaea1ce ("ALSA: core: add hooks for audio timestamps") only
> added the legacy .wall_clock hook. Commit 3179f6200188 ("ALSA: core: add
> .get_time_info") introduced update_audio_tstamp(), the type_requested !=
> SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT guard around ->get_time_info(), and
> the mismatched actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT check.
>
Thanks. I'll wait for the review comments from Takashi and Jaroslav,
and fold them together with the Fixes tag correction into v2.
Thanks
Best Regards
Hao
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 8:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 7:41 [PATCH] ALSA: pcm: derive the audio timestamp for the DEFAULT type Hao Ge
2026-11-30 7:56 ` sashiko-bot
2026-11-30 8:16 ` Hao Ge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox