8000 ALSA: timer: Fix negative queue usage by racy accesses · bsd-unix/linux@3fa6993 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fa6993

Browse files
committed
ALSA: timer: Fix negative queue usage by racy accesses
The user timer tu->qused counter may go to a negative value when multiple concurrent reads are performed since both the check and the decrement of tu->qused are done in two individual locked contexts. This results in bogus read outs, and the endless loop in the user-space side. The fix is to move the decrement of the tu->qused counter into the same spinlock context as the zero-check of the counter. Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 046e9ce commit 3fa6993

File tree

Collapse file tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sound/core/timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
19551955

19561956
qhead = tu->qhead++;
19571957
tu->qhead %= tu->queue_size;
1958+
tu->qused--;
19581959
spin_unlock_irq(&tu->qlock);
19591960

19601961
if (tu->tread) {
@@ -1968,7 +1969,6 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
19681969
}
19691970

19701971
spin_lock_irq(&tu->qlock);
1971-
tu->qused--;
19721972
if (err < 0)
19731973
goto _error;
19741974
result += unit;

0 commit comments

Comments
 (0)
0