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 174862EA48B; Tue, 22 Jul 2025 13:50:34 +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=1753192234; cv=none; b=HZGkOx4MHAVj+lx91TMC4LxFvILWkrxmMOLRoJLV6/YAoOClcZqNowGj5kSeoqZ7poElpvfEm30i0gkFPDqFsqVK5IpvjXIQAdAEsAjTRvnmS1B6lj/qi9w1VEZF4OowQ2NYiVSJ7W6IkWFkwC5OMb5aIzOmb0s7asNv8ARD//s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753192234; c=relaxed/simple; bh=u9hbEAoDXnpePIYlFULSSKHOrRTbtM7L+B+ZrACRNcg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pvpOq1pav7QwO6vksWKmgF8XnhQf2O1tFRXFK370ZKKTn4yh8ALNg1Dbc1bOTSJkIjem2M+JkKiHucj4aBxW50ThtoDmgjcFeDQzHjhABJ+IpIbxl5Xc8HCj53XlaX9AcMzzO82Rokz9HAxDjK2w/3FNgxp+2d3fOIIRgTyaDgk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=T4mjofJw; 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="T4mjofJw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A230C4CEEB; Tue, 22 Jul 2025 13:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753192234; bh=u9hbEAoDXnpePIYlFULSSKHOrRTbtM7L+B+ZrACRNcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4mjofJwnd3bCIVB0qeYRxCy8j002Nba8ZWFqOjl41/7GDl7kLpuWm76d459bALcZ aYlErmcGH0xad2r6HbbF6ihB+/78W+1fX5EyWoiIQx504lu+j7SVQrsYX7Y4jjCpzr uu/A1OY2+CZ9QbMj1czfT+KeAe1JE00XvV7/I3yA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+3bbbade4e1a7ab45ca3b@syzkaller.appspotmail.com, Marius Zachmann , Guenter Roeck , Sasha Levin Subject: [PATCH 6.1 50/79] hwmon: (corsair-cpro) Validate the size of the received input buffer Date: Tue, 22 Jul 2025 15:44:46 +0200 Message-ID: <20250722134330.219273431@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250722134328.384139905@linuxfoundation.org> References: <20250722134328.384139905@linuxfoundation.org> User-Agent: quilt/0.68 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-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marius Zachmann [ Upstream commit 495a4f0dce9c8c4478c242209748f1ee9e4d5820 ] Add buffer_recv_size to store the size of the received bytes. Validate buffer_recv_size in send_usb_cmd(). Reported-by: syzbot+3bbbade4e1a7ab45ca3b@syzkaller.appspotmail.com Closes: https://lore.kernel.org/linux-hwmon/61233ba1-e5ad-4d7a-ba31-3b5d0adcffcc@roeck-us.net Fixes: 40c3a4454225 ("hwmon: add Corsair Commander Pro driver") Signed-off-by: Marius Zachmann Link: https://lore.kernel.org/r/20250619132817.39764-5-mail@mariuszachmann.de Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/corsair-cpro.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hwmon/corsair-cpro.c b/drivers/hwmon/corsair-cpro.c index 486fb6a8c3566..18da3e013c20b 100644 --- a/drivers/hwmon/corsair-cpro.c +++ b/drivers/hwmon/corsair-cpro.c @@ -84,6 +84,7 @@ struct ccp_device { struct mutex mutex; /* whenever buffer is used, lock before send_usb_cmd */ u8 *cmd_buffer; u8 *buffer; + int buffer_recv_size; /* number of received bytes in buffer */ int target[6]; DECLARE_BITMAP(temp_cnct, NUM_TEMP_SENSORS); DECLARE_BITMAP(fan_cnct, NUM_FANS); @@ -139,6 +140,9 @@ static int send_usb_cmd(struct ccp_device *ccp, u8 command, u8 byte1, u8 byte2, if (!t) return -ETIMEDOUT; + if (ccp->buffer_recv_size != IN_BUFFER_SIZE) + return -EPROTO; + return ccp_get_errno(ccp); } @@ -150,6 +154,7 @@ static int ccp_raw_event(struct hid_device *hdev, struct hid_report *report, u8 spin_lock(&ccp->wait_input_report_lock); if (!completion_done(&ccp->wait_input_report)) { memcpy(ccp->buffer, data, min(IN_BUFFER_SIZE, size)); + ccp->buffer_recv_size = size; complete_all(&ccp->wait_input_report); } spin_unlock(&ccp->wait_input_report_lock); -- 2.39.5