From: Takashi Iwai <tiwai@suse.de>
To: Yuqiang Sun <izaiahsun@gmail.com>
Cc: perex@perex.cz, tiwai@suse.com, wesley.cheng@oss.qualcomm.com,
raoxu@uniontech.com, linux-sound@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] ALSA: usb-audio: qcom: Check the return value of qmi_handle_init()
Date: Mon, 02 Nov 2026 09:50:52 +0100 [thread overview]
Message-ID: <87ld7b4nwz.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261102035237.56253-1-izaiahsun@gmail.com>
On Mon, 02 Nov 2026 04:52:37 +0100,
Yuqiang Sun wrote:
>
> qc_usb_audio_probe() overwrites the return value of qmi_handle_init()
> with that of qmi_add_server() without checking it. When
> qmi_handle_init() fails, it has already freed the receive buffer and
> destroyed the workqueue, and qmi->sock may hold an error pointer. If
> QRTR is not available, qmi_handle_init() returns -EPROBE_DEFER and
> qmi->sock is ERR_PTR(-EAFNOSUPPORT), so qmi_add_server() passes it to
> kernel_sendmsg():
>
> BUG: unable to handle page fault for address: ffffffffffffffb7
> RIP: 0010:selinux_socket_sendmsg+0xa0/0x590
> Call Trace:
> security_socket_sendmsg+0x29/0x50
> __sock_sendmsg+0x43/0x150
> kernel_sendmsg+0xd6/0x180
> qmi_send_new_server+0x1b8/0x2b0
> qmi_add_server+0x165/0x200
> qc_usb_audio_probe+0xf4/0x2e0
> really_probe+0x2b4/0x850
>
> Had the probe gone on, the error and remove paths would call
> qmi_handle_release() on the half-initialized handle, which destroys the
> workqueue and frees the receive buffer a second time.
>
> Return the error from qmi_handle_init(), so that -EPROBE_DEFER defers
> the probe, and check qmi_add_server() as well.
>
> The bug was found with kbound, a static analysis prototype for
> ownership mismatches at kernel interfaces, on v7.2.12; it is present in
> mainline.
>
> Build-tested with x86_64 and arm64 allmodconfig (W=1, sparse): no new
> warnings. Run-tested on QEMU (x86_64, KVM) with KASAN and kmemleak, with
> the driver built in and a test module that registers the
> q6usb.qc-usb-audio-offload auxiliary device. Without QRTR, the probe
> crashes as above without this patch; with it the device is deferred and
> removing it again reports nothing. With QRTR the probe succeeds, and
> removal reports nothing either.
>
> Fixes: 326bbc348298 ("ALSA: usb-audio: qcom: Introduce QC USB SND offloading support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuqiang Sun <izaiahsun@gmail.com>
Applied now. Thanks.
Takashi
prev parent reply other threads:[~2026-11-02 8:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 3:52 Yuqiang Sun
2026-11-02 8:50 ` 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=87ld7b4nwz.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=izaiahsun@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=raoxu@uniontech.com \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.com \
--cc=wesley.cheng@oss.qualcomm.com \
/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
all inboxes | Powered by JetHome®