Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Bin Yu <byu@xidian.edu.cn>,
	Cheng Wen <wencheng@xidian.edu.cn>
Subject: Re: [PATCH v6] ALSA: line6: Stop URBs synchronously via sync_stop callback
Date: Mon, 23 Nov 2026 09:58:54 +0100	[thread overview]
Message-ID: <874id7exf5.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261122104039.7160-1-25031212351@stu.xidian.edu.cn>

On Sun, 22 Nov 2026 11:40:39 +0100,
YuanZhe Liu wrote:
> 
> line6_buffer_release() frees the stream buffer after
> line6_wait_clear_audio_urbs() gave up waiting for the URBs that are still
> active.  The buffer is still referenced by those URBs, and the completion
> callback of such an URB resubmits it from submit_audio_out_urb() with
> line6pcm->out.buffer already set to NULL, which ends up in a NULL pointer
> dereference in the memset() in submit_audio_out_urb().
> 
> While the URBs remain queued, the host controller can also write the
> received isochronous data into the freed buffer.  Such a write does not go
> through the KASAN checks, so it silently corrupts the freed slab object;
> the corruption was observed as a bogus KASAN quarantine entry that later
> led to a general protection fault in qlist_free_all().
> 
> The active_urbs bitmap cannot prove that the URBs are gone:
> line6_unlink_audio_urbs() is called outside the stream lock and only marks
> the URBs that are active at that moment, so an URB resubmitted by a
> completion callback right after the scan is never unlinked and keeps being
> resubmitted after the stream was stopped.
> 
> Stop the URBs synchronously instead of polling for them: mark the URBs
> that are currently active under the stream lock, so that the completion
> callbacks cannot resubmit them, and kill them with usb_kill_urb(), which
> waits for the giveback.  Expose this through the sync_stop PCM op, which
> ALSA core invokes before hw_free(), hw_params() and prepare() once the
> stream was stopped, so the buffer is guaranteed to be unused when it is
> released.
> 
> The URBs are marked and killed only while no stream is running on that
> stream, and only those that are active at that moment, so neither a
> stream started concurrently nor another stream type still running
> (software monitoring, impulse or the capture helper) is stopped.
> Unlink marks left on already completed URBs are dropped afterwards, while
> those of still active URBs are kept, so that a later stream start can
> submit the URBs again.
> 
> line6_pcm_acquire() and snd_line6_prepare() keep a synchronous stop for
> an idle stream as well: sync_stop() is invoked only when the substream
> itself was stopped, while the other stream types sharing the same stream
> never set that, and their unlinking URBs would make
> line6_stream_start() skip the submission.  line6_pcm_disconnect() and
> line6_buffer_release() stop the URBs unconditionally, as the device may
> be gone already and the buffer is about to be freed.
> 
> The helper skips the loop when the URBs were not created, as
> line6_pcm_disconnect() may run after a failed probe.
> 
> 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 now.  If you have further fix, please give
an incremental fix.


thanks,

Takashi

      reply	other threads:[~2026-11-23  8:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 10:40 [PATCH v3] ALSA: line6: Kill URBs before releasing the PCM buffer YuanZhe Liu
2026-11-22  8:16 ` Takashi Iwai
2026-11-22  9:04   ` [PATCH v4] ALSA: line6: Stop URBs synchronously via sync_stop callback YuanZhe Liu
2026-11-22  9:34   ` [PATCH v5] " YuanZhe Liu
2026-11-22 10:40   ` [PATCH v6] " YuanZhe Liu
2026-11-23  8:58     ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874id7exf5.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=25031212351@stu.xidian.edu.cn \
    --cc=byu@xidian.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=stable@vger.kernel.org \
    --cc=wencheng@xidian.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox