From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8ABD233CE9A; Fri, 9 Jan 2026 12:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767960084; cv=none; b=X6RD0S4jWrU+2yHIkeBiu5vK+gEwMvCm0EB9l+pHILmZbUGNZ8xsEVWb1FK8LxgcWg9A0gRbQhMQ8glP1wuyRPOwKmQta6WxUL7cnUDF3x2bmFyqG8Nxx51pAUQJI7ANpaNF7SS3pEkIVkXtVcu3/0f9n1jLzygQV7eRThAlb9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767960084; c=relaxed/simple; bh=Wh55LbmL4y68Nx+oHBTqpMsfRqsvfKp7JskPKEUJKdc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J3L3YcndGViQE/XKKQp9YBYOV5Gsd76BneepNkFpzbeRFZKDUmxpm2UmyhZ1Akjmg6GuH2D+0W5CzfsiDwQFTjyVGC9q6os0RzXkX338olX7ImAqaLJbfffO7EA/dm5SrpwrlyjcRmytVcvU5VUWWQimZPABFFN0WTepa3gq6d4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kyION0x6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kyION0x6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D273DC4CEF1; Fri, 9 Jan 2026 12:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767960084; bh=Wh55LbmL4y68Nx+oHBTqpMsfRqsvfKp7JskPKEUJKdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kyION0x6he0X1iuyqbe/iA6Mo6VH75BwNNYI+ElFRchmCCWdp353NRZRFDbQTR8lH fH9r36hYP+m/HDQw6h3ApL6LNcHPCgh//BRJ2mhuWfvhMrdpMBihIvOQ1AxywU4Ivi xTTVpQvk5ux09E03PVF9NT5AhLrx0YLaogxQLTCQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuhao Jiang , Junrui Luo , Takashi Iwai , Sasha Levin Subject: [PATCH 6.6 278/737] ALSA: firewire-motu: fix buffer overflow in hwdep read for DSP events Date: Fri, 9 Jan 2026 12:36:57 +0100 Message-ID: <20260109112144.466657122@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112133.973195406@linuxfoundation.org> References: <20260109112133.973195406@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junrui Luo [ Upstream commit 210d77cca3d0494ed30a5c628b20c1d95fa04fb1 ] The DSP event handling code in hwdep_read() could write more bytes to the user buffer than requested, when a user provides a buffer smaller than the event header size (8 bytes). Fix by using min_t() to clamp the copy size, This ensures we never copy more than the user requested. Reported-by: Yuhao Jiang Reported-by: Junrui Luo Fixes: 634ec0b2906e ("ALSA: firewire-motu: notify event for parameter change in register DSP model") Signed-off-by: Junrui Luo Link: https://patch.msgid.link/SYBPR01MB78810656377E79E58350D951AFD9A@SYBPR01MB7881.ausprd01.prod.outlook.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/firewire/motu/motu-hwdep.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/firewire/motu/motu-hwdep.c b/sound/firewire/motu/motu-hwdep.c index a220ac0c8eb83..28885c8004aea 100644 --- a/sound/firewire/motu/motu-hwdep.c +++ b/sound/firewire/motu/motu-hwdep.c @@ -83,10 +83,11 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, event.motu_register_dsp_change.type = SNDRV_FIREWIRE_EVENT_MOTU_REGISTER_DSP_CHANGE; event.motu_register_dsp_change.count = (consumed - sizeof(event.motu_register_dsp_change)) / 4; - if (copy_to_user(buf, &event, sizeof(event.motu_register_dsp_change))) + if (copy_to_user(buf, &event, + min_t(long, count, sizeof(event.motu_register_dsp_change)))) return -EFAULT; - count = consumed; + count = min_t(long, count, consumed); } else { spin_unlock_irq(&motu->lock); -- 2.51.0