From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.38 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796292081; b=iHkzAIP+4J+du0L9X0EMYAQITBMAP1Ols6sRBifWjE7yTOgBjMtitIL2R5eD2ocuT/9B ayXKLFzqybkQr5uVnTe5tskTJadO3Jkx2IU0wEaE2lGld8Qa3l3Qz1VsEILTocef1yjc5 /q238cumaZ3F4ZxurDkxDJ/tC9VDK66OtlL8Ez+ff1U5XC9YGZuxuTCFGng9gkTcjjjo/ l5itSaco0JIbGRXILBg/7Z8rFmbNpP+/gKGonc4Qe7k5AXS85lvW9l+AETlx9Z6rstZbf ke0gnvwIU+KXmUzQbHgbnLV3uBvcQqaUpb0uSm8+aB53cPPyeXoC2JA0SHYV7wuek5A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796292081; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-Id: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=XuJ8phoAQUJ6pn55NGj11uvXVjy7MbbSkHQuoRHkB/w=; b=K3UqZ3zqyTvCMXcQrOpBWoF1Eb1ZzzU1gYPypkInDQF/Koisr62JePVEHqopKkhpBNfE ipv15Ux2IdBIdNC3+XkLDVs+aanlk2iP7hLtBI0zH/v45egvNwE5lHlcwuEcCvktxS8C5 fi7/j9OjtZT7CIXkBGA9CJ6nHUlj0NjDdekZhsvfCNNGBqJxqf4zzdronCwt8vWv4Qe31 iqNknJRtPUgjR0E05MI3s2Sxr8HQRRhOI3DzAJfb5HGynYOekwCLprTcwO8QlmjPucqx5 5oy1rP6o3tnMy4F9mvv93ZMAUvZkx3M7fcWmo7VlVx6TM66LgeNPjSVv/ORNYr/EHPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=XFu9bNu3; arc=none smtp.remote-ip=95.215.58.38 Received: from mta1.migadu.com (out-38.mta1.migadu.com [95.215.58.38]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2D41606A322 for ; Thu, 3 Dec 2026 10:01:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B2D41606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=XFu9bNu3 X-Envelope-To: linux-sound@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=BipaerLrJ27CN7wZUb9XVrrZqINnjrrPM6Rp8HVZ+4U=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796292078; v=1; x=1796896878; b=XFu9bNu3tQD+FnDPZ4Eig41+it9J64vd/3grM3N4FtwgxDDoM/c+6GfjnJt6TA6zQqRuKKUp mSslI/7rXwEvrN+QwAURJS6fvG6iaP4qB2p7TDz5F4AKSU3j+wLmaVYOxd3OJahdqzNHLlQaRMb bWibNLST7KI+XsBmXB+fUSXg= X-Envelope-To: linux-sound@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 6b5a9dc5e5e06411; Thu, 03 Dec 2026 10:01:18 +0000 X-Mizu-Trace-ID: 6b5a9dc5e5e06411 X-Migadu-Flow: FLOW_OUT From: Hao Ge To: Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, Hao Ge , stable@vger.kernel.org Subject: [PATCH v2] ALSA: pcm: derive the audio timestamp for the DEFAULT type Date: Thu, 3 Dec 2026 18:01:09 +0800 Message-Id: <20261203100109.170640-1-hao.ge@linux.dev> X-Mailer: git-send-email 2.25.1 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 3179f6200188 ("ALSA: core: add .get_time_info") Cc: stable@vger.kernel.org Signed-off-by: Hao Ge --- 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