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 AB00A39B4A5; Sat, 17 Oct 2026 17:11:48 +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=1792257109; cv=none; b=ALSwgHMWJucuuFMdTlnpOlLK9f8HAOXUCgPo2xhdSJJxxYC76PR/OsWi257y/psXrJ8YzEd+PcR7lVJrYq2+HyIjZjukPbOZhlyBYhnHOg162EfZs64IosCDPZX91YZ8DwS4RGPHTflGDhIje1agf/IvAK6P4WpQXg9tin5r9mA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792257109; c=relaxed/simple; bh=KiVx7fmkrmC5m5xYcz/G0o/+BgGGz+fSywSEVzF1bUY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IrDHYEHJuIQMfhq02P/oqwbYaWXmlPQsj14ID62+eUk3BsDTv6Dh29AEIXH8wKRXgNxNm7NLnl/1tOjS4wLb4D2cYtpilgE/qNdSqMJ06Wyg2wFxQxfBNQRcW5ZE9/jEH0yPAw1x0lQP9aA1olxIT6EbU7f4B01RodFFF00D/oc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FzxXun2h; 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="FzxXun2h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0269C1F000C4; Sat, 17 Oct 2026 17:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792257108; bh=QDraoRzp+gpdXLhzqkqsiafUkl+BQUaIyKzYZ03ggxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FzxXun2hbaQFB5irXgRje7Oak8Gnu5t+xQ8Z0IDAhuKZW3Ote00QeOwoI+ISm0mWN x6EL0QJZVOtXUTTshdBYAdZKu6MyWukXAIAWcL1z4C4gipDAQzrf8qZ5TYTmrQtMnO m591VH6n6fKqovVB/iWtBbKmq532Psu5zobECJHc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Carlos Llamas , Lee Jones , Jiri Kosina , Sasha Levin Subject: [PATCH 6.6 0454/1674] HID: uhid: convert to hid_safe_input_report() Date: Sat, 17 Oct 2026 17:45:26 +0200 Message-ID: <20261017160442.770177996@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@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-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Carlos Llamas [ Upstream commit 63a694c51bf120a37550890b8e7736b4888985e9 ] Commit 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()"), added a check in hid_report_raw_event() to reject reports if the received data size is smaller than expected. This was intended to prevent OOB errors by no longer allowing zeroing-out of shorter reports due to the lack of buffer size information. However, this leads to regressions in hid_report_raw_event(), where shorter than expected reports are rejected, even though their buffers are sufficiently large to be zero-padded. To solve this issue, Benjamin introduced a safer alternative in commit 206342541fc8 ("HID: core: introduce hid_safe_input_report()"), which forwards the buffer size and allows hid_report_raw_event() to safely zero-pad the data. Convert uhid to use hid_safe_input_report() and pass UHID_DATA_MAX as the buffer size. This prevents the reported regressions [1], allowing hid core to zero-pad the shorter reports safely as expected. Cc: stable@vger.kernel.org Fixes: 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()") Closes: https://lore.kernel.org/all/ahsh0UtTX6e0ZeHa@google.com/ [1] Signed-off-by: Carlos Llamas Reviewed-by: Lee Jones Closes: https://lore.kernel.org/all/ahsh0UtTX6e0ZeHa@google.com/ Signed-off-by: Jiri Kosina Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/hid/uhid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 4588d2cd4ea44..9027bb23f247a 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c @@ -596,8 +596,8 @@ static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev) if (!READ_ONCE(uhid->running)) return -EINVAL; - hid_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input.data, - min_t(size_t, ev->u.input.size, UHID_DATA_MAX), 0); + hid_safe_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input.data, UHID_DATA_MAX, + min_t(size_t, ev->u.input.size, UHID_DATA_MAX), 0); return 0; } @@ -607,8 +607,8 @@ static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev) if (!READ_ONCE(uhid->running)) return -EINVAL; - hid_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input2.data, - min_t(size_t, ev->u.input2.size, UHID_DATA_MAX), 0); + hid_safe_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input2.data, UHID_DATA_MAX, + min_t(size_t, ev->u.input2.size, UHID_DATA_MAX), 0); return 0; } -- 2.53.0