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 X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E65C433FF for ; Wed, 14 Aug 2019 02:27:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D310F2085A for ; Wed, 14 Aug 2019 02:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565749650; bh=MLP40Xee1XZVetBmWFSJCKBW+PStioixF9jdljQ31A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KyVaC/Z/r5FqcEOQd1QjdQ5utM25M7XQ2xIcfFtDZsn4ZFwAWyyTEEhlQ5VCiTBxW x6eAKjSf9Eai7yBbsaB152LNm7ND9b5AFWxUB8lWmKUq8S8Am6N24s6+da9HpDKUOZ fSZuHWZwwQaJlLLhidtoiYEMOnHoAW+D+E1+OZqk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730310AbfHNC00 (ORCPT ); Tue, 13 Aug 2019 22:26:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:54514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730303AbfHNC0Z (ORCPT ); Tue, 13 Aug 2019 22:26:25 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A3A3A2184B; Wed, 14 Aug 2019 02:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565749584; bh=MLP40Xee1XZVetBmWFSJCKBW+PStioixF9jdljQ31A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UgEz98zv32t87/N7qWrT7uv8f10zSYPHRzmmG+K6WyUtxTuP4YKlxs7WzwbDHNSnr NxyUbdXYvdgO9uqYrPrAr47pPVmJv6Dt8IGcYXQtOxtFX+tWE/CAsGm/qtqnwySafp EjX5w4wHnuYPc1sqvCfYDF3BMPqWTNY9dg9SnKDY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oliver Neukum , syzbot+965152643a75a56737be@syzkaller.appspotmail.com, Jiri Kosina , Sasha Levin , linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 19/28] HID: holtek: test for sanity of intfdata Date: Tue, 13 Aug 2019 22:25:41 -0400 Message-Id: <20190814022550.17463-19-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190814022550.17463-1-sashal@kernel.org> References: <20190814022550.17463-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Oliver Neukum [ Upstream commit 01ec0a5f19c8c82960a07f6c7410fc9e01d7fb51 ] The ioctl handler uses the intfdata of a second interface, which may not be present in a broken or malicious device, hence the intfdata needs to be checked for NULL. [jkosina@suse.cz: fix newly added spurious space] Reported-by: syzbot+965152643a75a56737be@syzkaller.appspotmail.com Signed-off-by: Oliver Neukum Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-holtek-kbd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-holtek-kbd.c b/drivers/hid/hid-holtek-kbd.c index 6e1a4a4fc0c10..ab9da597106fa 100644 --- a/drivers/hid/hid-holtek-kbd.c +++ b/drivers/hid/hid-holtek-kbd.c @@ -126,9 +126,14 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type, /* Locate the boot interface, to receive the LED change events */ struct usb_interface *boot_interface = usb_ifnum_to_if(usb_dev, 0); + struct hid_device *boot_hid; + struct hid_input *boot_hid_input; - struct hid_device *boot_hid = usb_get_intfdata(boot_interface); - struct hid_input *boot_hid_input = list_first_entry(&boot_hid->inputs, + if (unlikely(boot_interface == NULL)) + return -ENODEV; + + boot_hid = usb_get_intfdata(boot_interface); + boot_hid_input = list_first_entry(&boot_hid->inputs, struct hid_input, list); return boot_hid_input->input->event(boot_hid_input->input, type, code, -- 2.20.1