public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ALSA: firewire-tascam: Do not drop unread control events
@ 2026-05-04  0:55 Cássio Gabriel
  2026-05-04  4:07 ` Takashi Sakamoto
  2026-05-04 11:30 ` Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Cássio Gabriel @ 2026-05-04  0:55 UTC (permalink / raw)
  To: Takashi Sakamoto, Clemens Ladisch, Takashi Iwai, Jaroslav Kysela
  Cc: linux-sound, linux-kernel, stable, Cássio Gabriel

tscm_hwdep_read_queue() copies as many queued control events as fit in
the userspace buffer. When the buffer is smaller than the current
contiguous queue segment, length is rounded down to the number of bytes
that can be copied.

However, after copying that shortened length, the code advances pull_pos
to the original tail_pos, marking the whole contiguous segment as
consumed. Any events between the copied portion and tail_pos are lost.

Limit tail_pos to the position after the entries actually copied before
updating pull_pos. When the whole segment fits, this is equivalent to the
old tail_pos update; when the buffer is smaller, the remaining events
stay queued for the next read.

Fixes: a8c0d13267a4 ("ALSA: firewire-tascam: notify events of change of state for userspace applications")
Cc: stable@vger.kernel.org
Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
---
Changes in v2:
- Recompute tail_pos after shortening length instead of adding a separate
  entries_copied variable, as suggested.
- Add Suggested-by tag.
- Link to v1: https://patch.msgid.link/20260501-alsa-firewire-tascam-read-queue-v1-1-7baa4ba1a4de@gmail.com
---
 sound/firewire/tascam/tascam-hwdep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c
index 867b4ea1096e..6270263e7bf4 100644
--- a/sound/firewire/tascam/tascam-hwdep.c
+++ b/sound/firewire/tascam/tascam-hwdep.c
@@ -73,6 +73,7 @@ static long tscm_hwdep_read_queue(struct snd_tscm *tscm, char __user *buf,
 			length = rounddown(remained, sizeof(*entries));
 		if (length == 0)
 			break;
+		tail_pos = head_pos + length / sizeof(*entries);
 
 		spin_unlock_irq(&tscm->lock);
 		if (copy_to_user(pos, &entries[head_pos], length))

---
base-commit: 9e8d6ddd7ecf2ad42d614243f86e50fcf0183b9e
change-id: 20260501-alsa-firewire-tascam-read-queue-7eaef1060adb

Best regards,
--  
Cássio Gabriel <cassiogabrielcontato@gmail.com>


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

* Re: [PATCH v2] ALSA: firewire-tascam: Do not drop unread control events
  2026-05-04  0:55 [PATCH v2] ALSA: firewire-tascam: Do not drop unread control events Cássio Gabriel
@ 2026-05-04  4:07 ` Takashi Sakamoto
  2026-05-04 11:30 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Sakamoto @ 2026-05-04  4:07 UTC (permalink / raw)
  To: Cássio Gabriel
  Cc: Clemens Ladisch, Takashi Iwai, Jaroslav Kysela, linux-sound,
	linux-kernel, stable

Hi,

On Sun, May 03, 2026 at 09:55:52PM -0300, Cássio Gabriel wrote:
> tscm_hwdep_read_queue() copies as many queued control events as fit in
> the userspace buffer. When the buffer is smaller than the current
> contiguous queue segment, length is rounded down to the number of bytes
> that can be copied.
> 
> However, after copying that shortened length, the code advances pull_pos
> to the original tail_pos, marking the whole contiguous segment as
> consumed. Any events between the copied portion and tail_pos are lost.
> 
> Limit tail_pos to the position after the entries actually copied before
> updating pull_pos. When the whole segment fits, this is equivalent to the
> old tail_pos update; when the buffer is smaller, the remaining events
> stay queued for the next read.
> 
> Fixes: a8c0d13267a4 ("ALSA: firewire-tascam: notify events of change of state for userspace applications")
> Cc: stable@vger.kernel.org
> Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
> ---
> Changes in v2:
> - Recompute tail_pos after shortening length instead of adding a separate
>   entries_copied variable, as suggested.
> - Add Suggested-by tag.
> - Link to v1: https://patch.msgid.link/20260501-alsa-firewire-tascam-read-queue-v1-1-7baa4ba1a4de@gmail.com
> ---
>  sound/firewire/tascam/tascam-hwdep.c | 1 +
>  1 file changed, 1 insertion(+)

Looks good to me;)

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

Or as a second Co-Author,
    Co-developed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
    Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

To maintainer, please feel free to assign the above tags according to
your preferences.


Thanks

Takashi Sakamoto

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

* Re: [PATCH v2] ALSA: firewire-tascam: Do not drop unread control events
  2026-05-04  0:55 [PATCH v2] ALSA: firewire-tascam: Do not drop unread control events Cássio Gabriel
  2026-05-04  4:07 ` Takashi Sakamoto
@ 2026-05-04 11:30 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2026-05-04 11:30 UTC (permalink / raw)
  To: Cássio Gabriel
  Cc: Takashi Sakamoto, Clemens Ladisch, Takashi Iwai, Jaroslav Kysela,
	linux-sound, linux-kernel, stable

On Mon, 04 May 2026 02:55:52 +0200,
Cássio Gabriel wrote:
> 
> tscm_hwdep_read_queue() copies as many queued control events as fit in
> the userspace buffer. When the buffer is smaller than the current
> contiguous queue segment, length is rounded down to the number of bytes
> that can be copied.
> 
> However, after copying that shortened length, the code advances pull_pos
> to the original tail_pos, marking the whole contiguous segment as
> consumed. Any events between the copied portion and tail_pos are lost.
> 
> Limit tail_pos to the position after the entries actually copied before
> updating pull_pos. When the whole segment fits, this is equivalent to the
> old tail_pos update; when the buffer is smaller, the remaining events
> stay queued for the next read.
> 
> Fixes: a8c0d13267a4 ("ALSA: firewire-tascam: notify events of change of state for userspace applications")
> Cc: stable@vger.kernel.org
> Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>

Applied now.  Thanks.


Takashi

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

end of thread, other threads:[~2026-05-04 11:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04  0:55 [PATCH v2] ALSA: firewire-tascam: Do not drop unread control events Cássio Gabriel
2026-05-04  4:07 ` Takashi Sakamoto
2026-05-04 11:30 ` Takashi Iwai

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