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 04D3439B6AA; Tue, 16 Dec 2025 12:37:42 +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=1765888662; cv=none; b=Hexr4a/jCY95Ko1yBiwfgMIJ3rGCs0Q9rCOqL3V69NY8RPCMMOfKQtwZmIUPiVXscrf7ykoFqxBhLV/fFkFumwjSrlfW3/0Vy74QoZsEFqGIX7OwyZelWd4MsyCbjehSOWVhcPqtmLQQQqnAsbMVl1kbtQhUeCFNUUVjNgRyccQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765888662; c=relaxed/simple; bh=Tj6uZZHt3hDOGUFegeWtf61yyIyx6pgNvJBg06fhV3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OOKnqIROts0wwL1gDSOOS2YLyrdk3ZuDGgNU/vRZzUUOlSjUOFNBkwQRtptwuxHB7bEPDsDVVHWoi+pK2VyFa6X8k8brcCvO5F02Rq6ALVmGS+VUsfHga/ZpBE/wGQKlIKWvlV7Yyi7e2dJ4A5+1R/aZB1tEXoNfv4m6DSaacB4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=d6bo3YZd; 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="d6bo3YZd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8320DC4CEF1; Tue, 16 Dec 2025 12:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1765888661; bh=Tj6uZZHt3hDOGUFegeWtf61yyIyx6pgNvJBg06fhV3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d6bo3YZd6pSUVv11Nyrsy0a4bNgCT2nUrKAMBDr9F4fbHZY2cK9NIQXjnEXI99+CQ zXptgHH2IfG0H2BH3tiO6GwYAEPmCYMhNYNDEU6yLIF16u3Ff18PoUWdROtneoLcTi codc4u62GeBabE0kO7IEVJtSW6k+1oC3Nm/Y+WmA= 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.18 567/614] ALSA: firewire-motu: fix buffer overflow in hwdep read for DSP events Date: Tue, 16 Dec 2025 12:15:34 +0100 Message-ID: <20251216111421.928220410@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251216111401.280873349@linuxfoundation.org> References: <20251216111401.280873349@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.18-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 981c19430cb0f..6675b23aad69e 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