From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B260931F9AC; Sun, 7 Jun 2026 10:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828947; cv=none; b=KjWwoVJt15jtig06Cr2CPK82qBuPZ5Q/y2P+Jf9M2jjyqOulZgrHlS4PDaiMBnxM5ypTydnPqq6VZ24YbqIbPRB0GBzz+bQxW1awBOWssqxzCRZLB4OvHKM1LvjBBGolytb6LsuTiEx4+muldN+W1vsESKlLlTJZlzexiTofexQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828947; c=relaxed/simple; bh=pF28KkFjDS2v3SbQHs4ZKBwUqhG5VFgARd/sV9Iu9fg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HtGA7l/JgbTr6N7kDXJap5d/5MkjYO8PVujruUn04p8bmEhIylumNSaSyMbxlhTQ10Laa8Fri63gOAEUR4RtNRyKGEp91qMTNIcL8F2C05k6TRv6b72TodPGwYlgZ87gq+B5zqc1bcmlyrahNlUN/hPzPs+FnnF0bfa6y10T/bA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=P3v9xohM; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="P3v9xohM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12A941F00893; Sun, 7 Jun 2026 10:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780828946; bh=KY1sX9WjkS5xxqgSQ783Oflw7GWOi+fzS+DPnwv1z9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=P3v9xohMyGoGp5UzvaZfhlfx1i6Ghdwn/722GOMtRTuQReSQWULVUGZOm9Mo2lTCV GY3yFBFqdK/CTx3WbD45u0r3bF0IjhljGVVUL1NKKPkaPVjAMn1uUo3shTaL3+PIVb Rc0CxdEdCfs4PZyVhutiH+XU7hzJwDiAXqYf1Uqg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?C=C3=A1ssio=20Gabriel?= , Takashi Sakamoto , Takashi Iwai Subject: [PATCH 6.18 204/315] ALSA: firewire-motu: Protect register DSP event queue positions Date: Sun, 7 Jun 2026 11:59:51 +0200 Message-ID: <20260607095735.061182744@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.528828913@linuxfoundation.org> References: <20260607095727.528828913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cássio Gabriel commit 98fb1c1bb11e29eb609b7200a25e136e05aa4498 upstream. The register DSP event queue is updated under parser->lock, but snd_motu_register_dsp_message_parser_count_event() reads pull_pos and push_pos without the lock. snd_motu_register_dsp_message_parser_copy_event() also reads both queue positions before taking the lock. Protect these accesses with parser->lock as well. This keeps the hwdep poll/read path consistent with the producer side and with the cached meter/parameter accessors. Fixes: 634ec0b2906e ("ALSA: firewire-motu: notify event for parameter change in register DSP model") Cc: stable@vger.kernel.org Signed-off-by: Cássio Gabriel Reviewed-by: Takashi Sakamoto Signed-off-by: Takashi Iwai Link: https://patch.msgid.link/20260521-alsa-firewire-motu-event-locking-v1-1-708e1c2b5e56@gmail.com Signed-off-by: Greg Kroah-Hartman --- sound/firewire/motu/motu-register-dsp-message-parser.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/sound/firewire/motu/motu-register-dsp-message-parser.c +++ b/sound/firewire/motu/motu-register-dsp-message-parser.c @@ -386,6 +386,8 @@ unsigned int snd_motu_register_dsp_messa { struct msg_parser *parser = motu->message_parser; + guard(spinlock_irqsave)(&parser->lock); + if (parser->pull_pos > parser->push_pos) return EVENT_QUEUE_SIZE - parser->pull_pos + parser->push_pos; else @@ -395,13 +397,14 @@ unsigned int snd_motu_register_dsp_messa bool snd_motu_register_dsp_message_parser_copy_event(struct snd_motu *motu, u32 *event) { struct msg_parser *parser = motu->message_parser; - unsigned int pos = parser->pull_pos; - - if (pos == parser->push_pos) - return false; + unsigned int pos; guard(spinlock_irqsave)(&parser->lock); + if (parser->pull_pos == parser->push_pos) + return false; + + pos = parser->pull_pos; *event = parser->event_queue[pos]; ++pos;