* [PATCH] ALSA: line6: Clear prev_fbuf on capture buffer release
@ 2026-10-13 6:35 Yuanzhe Liu
2026-10-13 7:08 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Yuanzhe Liu @ 2026-10-13 6:35 UTC (permalink / raw)
To: Takashi Iwai, Jaroslav Kysela
Cc: linux-sound, linux-kernel, stable, Bin Yu, Cheng Wen, YuanZhe Liu
From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
A KASAN slab-use-after-free read was reported in submit_audio_out_urb()
when generating an impulse test signal:
BUG: KASAN: slab-use-after-free in create_impulse_test_signal sound/usb/line6/playback.c:76 [inline]
BUG: KASAN: slab-use-after-free in submit_audio_out_urb+0x1848/0x1b20 sound/usb/line6/playback.c:249
Read of size 2 at addr ffff888008d74870 by task syz.2.3214/7785
Allocated by task 11:
kmem_cache_alloc_noprof+0x2f0/0x390 mm/slub.c:4144
line6_buffer_acquire+0x1a1/0x220 sound/usb/line6/pcm.c:158
line6_pcm_acquire+0xb6/0x230 sound/usb/line6/pcm.c:329
line6_startup_work+0x3c/0x50 sound/usb/line6/driver.c:728
Freed by task 7785:
kfree+0xf8/0x390 mm/slub.c:6566
line6_buffer_release sound/usb/line6/pcm.c:176 [inline]
line6_buffer_release+0xa5/0xf0 sound/usb/line6/pcm.c:170
__line6_pcm_release sound/usb/line6/pcm.c:305 [inline]
line6_pcm_release+0x5a/0x80 sound/usb/line6/pcm.c:313
snd_toneport_monitor_put+0x11b/0x190 sound/usb/line6/toneport.c:183
line6pcm->prev_fbuf points into the capture PCM stream buffer
(line6pcm->in.buffer), which is updated during audio_in_callback() to
feed rate synchronization, software monitoring, and impulse test signal
generation on playback side.
When all capture streams are closed, line6_buffer_release() frees
pstr->buffer with kfree(). However, it does not clear line6pcm->prev_fbuf.
If playback is subsequently started (e.g. via impulse test signal
volume control snd_line6_impulse_volume_put()), submit_audio_out_urb()
dereferences the stale pointer line6pcm->prev_fbuf under in.lock,
resulting in a slab-use-after-free read.
Clear prev_fbuf and prev_fsize in line6_buffer_release() when releasing
the capture stream buffer under in.lock, ensuring that no stale buffer
pointer can be accessed by submit_audio_out_urb().
Fixes: 63e20df1e5b2 ("ALSA: line6: Reorganize PCM stream handling")
Cc: stable@vger.kernel.org
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
---
sound/usb/line6/pcm.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c
index 2932eaf157f4..b4c594add1ae 100644
--- a/sound/usb/line6/pcm.c
+++ b/sound/usb/line6/pcm.c
@@ -173,6 +173,14 @@ static void line6_buffer_release(struct snd_line6_pcm *line6pcm,
clear_bit(type, &pstr->opened);
if (!pstr->opened) {
line6_wait_clear_audio_urbs(line6pcm, pstr);
+ if (pstr == &line6pcm->in) {
+ /* prev_fbuf points into the capture buffer we are about
+ * to free; drop it while no capture URB is in flight.
+ */
+ guard(spinlock_irqsave)(&line6pcm->in.lock);
+ line6pcm->prev_fbuf = NULL;
+ line6pcm->prev_fsize = 0;
+ }
kfree(pstr->buffer);
pstr->buffer = NULL;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: line6: Clear prev_fbuf on capture buffer release
2026-10-13 6:35 [PATCH] ALSA: line6: Clear prev_fbuf on capture buffer release Yuanzhe Liu
@ 2026-10-13 7:08 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-10-13 7:08 UTC (permalink / raw)
To: Yuanzhe Liu
Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel, stable,
Bin Yu, Cheng Wen
On Tue, 13 Oct 2026 08:35:54 +0200,
Yuanzhe Liu wrote:
>
> From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
>
> A KASAN slab-use-after-free read was reported in submit_audio_out_urb()
> when generating an impulse test signal:
>
> BUG: KASAN: slab-use-after-free in create_impulse_test_signal sound/usb/line6/playback.c:76 [inline]
> BUG: KASAN: slab-use-after-free in submit_audio_out_urb+0x1848/0x1b20 sound/usb/line6/playback.c:249
> Read of size 2 at addr ffff888008d74870 by task syz.2.3214/7785
>
> Allocated by task 11:
> kmem_cache_alloc_noprof+0x2f0/0x390 mm/slub.c:4144
> line6_buffer_acquire+0x1a1/0x220 sound/usb/line6/pcm.c:158
> line6_pcm_acquire+0xb6/0x230 sound/usb/line6/pcm.c:329
> line6_startup_work+0x3c/0x50 sound/usb/line6/driver.c:728
>
> Freed by task 7785:
> kfree+0xf8/0x390 mm/slub.c:6566
> line6_buffer_release sound/usb/line6/pcm.c:176 [inline]
> line6_buffer_release+0xa5/0xf0 sound/usb/line6/pcm.c:170
> __line6_pcm_release sound/usb/line6/pcm.c:305 [inline]
> line6_pcm_release+0x5a/0x80 sound/usb/line6/pcm.c:313
> snd_toneport_monitor_put+0x11b/0x190 sound/usb/line6/toneport.c:183
>
> line6pcm->prev_fbuf points into the capture PCM stream buffer
> (line6pcm->in.buffer), which is updated during audio_in_callback() to
> feed rate synchronization, software monitoring, and impulse test signal
> generation on playback side.
>
> When all capture streams are closed, line6_buffer_release() frees
> pstr->buffer with kfree(). However, it does not clear line6pcm->prev_fbuf.
> If playback is subsequently started (e.g. via impulse test signal
> volume control snd_line6_impulse_volume_put()), submit_audio_out_urb()
> dereferences the stale pointer line6pcm->prev_fbuf under in.lock,
> resulting in a slab-use-after-free read.
>
> Clear prev_fbuf and prev_fsize in line6_buffer_release() when releasing
> the capture stream buffer under in.lock, ensuring that no stale buffer
> pointer can be accessed by submit_audio_out_urb().
>
> Fixes: 63e20df1e5b2 ("ALSA: line6: Reorganize PCM stream handling")
> Cc: stable@vger.kernel.org
> Co-developed-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Bin Yu <byu@xidian.edu.cn>
> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Applied to for-next branch. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-13 7:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 6:35 [PATCH] ALSA: line6: Clear prev_fbuf on capture buffer release Yuanzhe Liu
2026-10-13 7:08 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox