From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1ED1C001E0 for ; Mon, 23 Oct 2023 11:50:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234610AbjJWLu4 (ORCPT ); Mon, 23 Oct 2023 07:50:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234609AbjJWLuz (ORCPT ); Mon, 23 Oct 2023 07:50:55 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91C4F5 for ; Mon, 23 Oct 2023 04:50:52 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CBEEC433C8; Mon, 23 Oct 2023 11:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698061852; bh=38qBZx41nuwd23dV8eVG33b1nfrdQJ/AELimoyvNYVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fq+maIWWBKc3fivbdxDGUjO+bQkoCyxubqg3ynOYxaeMnNilUzhDC61yog4L71NCd qw9D2pvLUnoDYC8Pi0tIgxJsHmSKgSQoPif2jLkyJSmMB7Vj3BZosTH3zmCs6RN4PE E7G75qu+OwV9qsVuwTh3ztmHe2MgqFjMEDM2HLF8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ma Ke , Jiri Kosina , Sasha Levin Subject: [PATCH 5.10 159/202] HID: holtek: fix slab-out-of-bounds Write in holtek_kbd_input_event Date: Mon, 23 Oct 2023 12:57:46 +0200 Message-ID: <20231023104831.154185496@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231023104826.569169691@linuxfoundation.org> References: <20231023104826.569169691@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ma Ke [ Upstream commit ffe3b7837a2bb421df84d0177481db9f52c93a71 ] There is a slab-out-of-bounds Write bug in hid-holtek-kbd driver. The problem is the driver assumes the device must have an input but some malicious devices violate this assumption. Fix this by checking hid_device's input is non-empty before its usage. Signed-off-by: Ma Ke Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-holtek-kbd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hid/hid-holtek-kbd.c b/drivers/hid/hid-holtek-kbd.c index 403506b9697e7..b346d68a06f5a 100644 --- a/drivers/hid/hid-holtek-kbd.c +++ b/drivers/hid/hid-holtek-kbd.c @@ -130,6 +130,10 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type, return -ENODEV; boot_hid = usb_get_intfdata(boot_interface); + if (list_empty(&boot_hid->inputs)) { + hid_err(hid, "no inputs found\n"); + return -ENODEV; + } boot_hid_input = list_first_entry(&boot_hid->inputs, struct hid_input, list); -- 2.40.1