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 601813D411F; Wed, 8 Apr 2026 18:29:06 +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=1775672946; cv=none; b=lGIEEG8jZDeDq+hShhhA+Pq+Axsn8RcIe5imfxm3i7FmfAHyCffp5B/oPzJiMMkTBXmEgf2DWwo1wO73mzgPahFrl05WesD9qk+AFWxHyOmfvI4z/zP2U6LooIekGRbPcDAX3neU9j2Rj/T0KhgF7nk578e49zJ8DJoddmxq7Kc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672946; c=relaxed/simple; bh=8enPmp2WT4ugWxww+xcvMZ9HRbxpvnuDI3thK1cle+c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RcW5zx3A/RlxKZNPu4CDI/oon8vIr1jPDQc79/3Mja/Yycq1/9qB3fBSYuMJzAvyR0kDAD51PwiYUEgBWGzVr/QmRsoKYOGTsYDF7axX5uSwKy55DQfeLBlC8Mu0tS6R25jdL2R9P5hlPHAufhD4XH5u1fViMskvffc31kdQh90= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=W68u96/X; 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="W68u96/X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C27D2C19425; Wed, 8 Apr 2026 18:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775672946; bh=8enPmp2WT4ugWxww+xcvMZ9HRbxpvnuDI3thK1cle+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W68u96/XdRAoFseIKBUfQrCpXw0fjgmYyYgMIvw5eAPb2WmE2m/c9oi+OpQATQUn1 cmzvTMBeBGACIgGdFkySWuEc9paHZgujN2GvmXhxVZ5q13EJ2i72v35Mqp36q2S+RM NUcStbxiZVO7l5t1o6uR4FjXxBRC51Ui/JJ628wE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Lee Jones , Benjamin Tissoires , Sasha Levin Subject: [PATCH 6.18 010/277] HID: core: Mitigate potential OOB by removing bogus memset() Date: Wed, 8 Apr 2026 19:59:55 +0200 Message-ID: <20260408175934.230129845@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175933.836769063@linuxfoundation.org> References: <20260408175933.836769063@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: Lee Jones [ Upstream commit 0a3fe972a7cb1404f693d6f1711f32bc1d244b1c ] The memset() in hid_report_raw_event() has the good intention of clearing out bogus data by zeroing the area from the end of the incoming data string to the assumed end of the buffer. However, as we have previously seen, doing so can easily result in OOB reads and writes in the subsequent thread of execution. The current suggestion from one of the HID maintainers is to remove the memset() and simply return if the incoming event buffer size is not large enough to fill the associated report. Suggested-by Benjamin Tissoires Signed-off-by: Lee Jones [bentiss: changed the return value] Signed-off-by: Benjamin Tissoires Signed-off-by: Sasha Levin --- drivers/hid/hid-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index a5b3a8ca2fcbc..f5587b786f875 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2057,9 +2057,10 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 * rsize = max_buffer_size; if (csize < rsize) { - dbg_hid("report %d is too short, (%d < %d)\n", report->id, - csize, rsize); - memset(cdata + csize, 0, rsize - csize); + hid_warn_ratelimited(hid, "Event data for report %d was too short (%d vs %d)\n", + report->id, rsize, csize); + ret = -EINVAL; + goto out; } if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) -- 2.53.0