Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1534944ybl; Thu, 22 Aug 2019 16:37:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9rkqwWREc/WKMODVog0VNJ2TU4Ygb6LK6Dw9MNjFc/boAwBxBevFiP8IG/wZ5JPJkUATJ X-Received: by 2002:a17:90a:2601:: with SMTP id l1mr2200782pje.65.1566517039116; Thu, 22 Aug 2019 16:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566517039; cv=none; d=google.com; s=arc-20160816; b=L3UQyiFJpHiCNqHA3xQQLxjxppg+hMeyg9k/UgUERSRh5xqTpncIIpPHYasAyIXN7T z9L7Wzib6mG7VsvllCNcnx0VNLLt7m9ihSHSI9NUQOHS+5YvA5CMsfRm9DWuqvnWK8T9 WslNHEV1oUJwECg1M64luJqRPKRWJwMHL17wxKpSyaaXhza6OzHtzXVbkSBynveqbR4O Q/PY/3x7Di/Go2JbzlsiuZDmJFPHF4Ak9+x+BT1fnjoQWHpFwSPg3SyzE6Zp2OExbNqa bp8MphFKdaw+BjZ3zS7MAHsm9Tb6oZEVSuia8ssywro7mp+n/AVWnvn821iQ54r4vEH5 WJtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UAlHIkAQ8AymggAbngZPWWaJW9vJclPIzVGGyOOAS9Y=; b=yk96rc0e5yVdPXnPbd40djg6JG1R10lL+z7+fXAh7bdILYnoSZmO0LRCKxJ7Jcj7hs qctg4SBIpX8do71J6J6GufikAWr7mv6+89j1VOfVxKzkF4lkOKmCmKcgYmSuK3kJ3EVd VjuxB89u7+vbbca4d2HX85d6B18MUDyXxSmywuxKeJ3PNFRzuLS375FX9UNR+8kvBK2c z5QAKa0GlblYRL9RxuBsAxxSSao+yrozjI6TGkhCIDgFSu3yB3lJzxHZnDfKa9hPWL2p j31VDsq5B2RWjSyHQIRUac5wR/+SH4YZU3b1BOQUghZwl9YpywBeWMg7+NjStU5Fp7O+ AzGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tn6VdA6X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e18si783074pjr.107.2019.08.22.16.37.03; Thu, 22 Aug 2019 16:37:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tn6VdA6X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391291AbfHVRRa (ORCPT + 99 others); Thu, 22 Aug 2019 13:17:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:58088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390337AbfHVRI1 (ORCPT ); Thu, 22 Aug 2019 13:08:27 -0400 Received: from sasha-vm.mshome.net (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (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 3EC0B2341C; Thu, 22 Aug 2019 17:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566493707; bh=lpxYxosWAYQE5h909HT3g8DPzYphC8qQJFSXHbQFpKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tn6VdA6XGRzOJqOs12kM3NBX/UlOp/EOEl1ZmndoM7N+eRx0xxeLL7SjIAL1C1ci/ ExOnpEkKKeKTtrIOdvMBA+NRuKiHBDewAEZz3glDneDz/dwIcgptD3RLDpFgceXg2i X7YPe+3TkMbFftSC6fTVNKuOpdOKSdFeTAiOf04c= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oliver Neukum , syzbot+965152643a75a56737be@syzkaller.appspotmail.com, Jiri Kosina , Greg Kroah-Hartman Subject: [PATCH 5.2 024/135] HID: holtek: test for sanity of intfdata Date: Thu, 22 Aug 2019 13:06:20 -0400 Message-Id: <20190822170811.13303-25-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190822170811.13303-1-sashal@kernel.org> References: <20190822170811.13303-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.10-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.2.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.2.10-rc1 X-KernelTest-Deadline: 2019-08-24T17:07+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oliver Neukum commit 01ec0a5f19c8c82960a07f6c7410fc9e01d7fb51 upstream. 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: Greg Kroah-Hartman --- 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 b3d502421b79d..0a38e8e9bc783 100644 --- a/drivers/hid/hid-holtek-kbd.c +++ b/drivers/hid/hid-holtek-kbd.c @@ -123,9 +123,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