Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp222966ybl; Thu, 22 Aug 2019 23:19:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwj4oYEcnVaN2s+/l08LjkM27QiuRxM0F0xFKV/M7ZiY55SRFmT/G2HzTEQiZU6iuMjOZiR X-Received: by 2002:a63:db45:: with SMTP id x5mr2489482pgi.293.1566541172313; Thu, 22 Aug 2019 23:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566541172; cv=none; d=google.com; s=arc-20160816; b=kBKk24VpEAeZyrusMpkvwJSPGmdG5dqMzUSeQRrrUiGSI7vImfOvRsGef1Lj1k1lDf tcFBWGaces6hPOUqlwMrOt/aBvxHk5mPYlh+nLQTzTcSWQwnR3QvqLjHOrYiIsD9yMBn CSjV6nl4VcjXmSpSZMaaaOVNboPn3f5Bsbjoo5FAVRZSGUuv2/rJ7c2NFMRFVqwz+Rv5 uPYPPOyQoewmd4jbhw4kuSimEcGA6JHEb1qnzFRIJbiTfvsPsQrD3HEdAN+yu1WPq3mw ROBX45DuKu23GgN6mn1vQNppAK+09g/5lJrbOZgMLlbAvtXWvgUkP8SWZEHfnwSCILyS M/zg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8Syg1TD6PdiC/lYWZ65zjwzuHxeN0aGnZWHOUGmN1oU=; b=ct/joXV1b9pwGRYCh6Q/l1WYQtkYla5V3smD/4RGhLNICl6tvAyLsLbge5O7FFEJsI Y3qlSbqE+zG0/tg5P/ujzFFn6FyLp2lxWYYxvp/eNb91JQYlxownCmMYoWIHEUjc3GEr mziAGBYidhYPhl2wSk6vsV/GNtsi0jtn/RqiTCsHjKFG7yeww1ChA6v1e1n+DkDH0GNM 3Gw2EgjGaHWM2BIwHr9VjiphyOYPwJ9zn6IP6GWZhdV2SgKE3e33VMYJj9KTD0BGjFOS yaZW8q5gnyH9UP4d4yjXw8VwNl0iEjL8bbcJsBuCSdh3g0+XV4k6GQV/AdX5l6LxzdKn um9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f+8x7Ghw; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b25si1200955pgl.270.2019.08.22.23.19.17; Thu, 22 Aug 2019 23:19:32 -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=f+8x7Ghw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405182AbfHVRmJ (ORCPT + 99 others); Thu, 22 Aug 2019 13:42:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:44310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391716AbfHVRXv (ORCPT ); Thu, 22 Aug 2019 13:23:51 -0400 Received: from localhost (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8AEAA23697; Thu, 22 Aug 2019 17:23:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494630; bh=6fU+9PuammxkfJEvmn0ipo4sM2/Oi5xnKuBsX/DqtLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f+8x7GhwUAJh+Mbu3XkD2DLBoe2GTJ8iN97+Uc9nUq+5z0eyitRhS28xjGLEFWMEI 0HR+88x9LYJkqN0QenASxdJzwW4OYBgxCFmuO2r+hNsApUoroZNRjjyIOlzXbsuXY4 0n/IIPKuOMkFQNVkBYqMEugEh/1PV7+3YyOkCtIM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+965152643a75a56737be@syzkaller.appspotmail.com, Oliver Neukum , Jiri Kosina Subject: [PATCH 4.9 062/103] HID: holtek: test for sanity of intfdata Date: Thu, 22 Aug 2019 10:18:50 -0700 Message-Id: <20190822171731.300815625@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190822171728.445189830@linuxfoundation.org> References: <20190822171728.445189830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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(-) --- 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 /* 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,