Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1964869rwe; Fri, 2 Sep 2022 06:42:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR7u1vD2w2Hbt6yi1RxNAlr98hPrNE3fKB5OcKVS4za8lu5EL5O+tyMW4Kc71XOVmYGs0Hz1 X-Received: by 2002:a05:6a00:1943:b0:53a:8602:6758 with SMTP id s3-20020a056a00194300b0053a86026758mr16423208pfk.47.1662126134494; Fri, 02 Sep 2022 06:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662126134; cv=none; d=google.com; s=arc-20160816; b=mizJI7lxrShYuNWN5SSl718clJiFIixGJEZsV9NIZfANknAvVogc9LL3KDg2m56I/T 99PF1qEoLlFBLSAKsfboy2ig826oXMNJPNfHGOk4UqRWFaEGmcxc3IdkzhV5ylKzWVgd cdNjr9fckLHibeESyuj5STLBhpiwCxN2CUUsNMoWX8M8JTbqksvGXcl4PCYaTO1Pfn79 D87ZAtRIvxt1q2aDvlGBAHwi0yvwKdPIvsEyXQTe0Ym4mGm7TTWjmxyVz9PUSLU8oJL9 mF2VC/aP/3kkEAA2lhJzNpuk+puX6abt/2qLO5U4Us2KUDTXtwaCNhcRd8MQvTpelHq+ L4rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=l2nDJ1Cecolwm7s6Adfa7Ld8ulZRDsbDzrIdf8uU05A=; b=Jn4+2zeZGvBZR/x55fZs54W/KhWHPDdarpWNT53gxicnKxhR8LIeftkzhvWfUqCZ5U 26JjdFvC2TzbGOqGM3J57dW41bv3F1mUplhrsjDNbkdmO3bYxzufk0mQn9FgXPayoKUS 6rtybka9pLu6KzYMQsSfJXSZkDHnoFr6CkWeX9XjJZyUuxyh4J+5r4N0xifZTfCM9+e7 dtvKx0nzQKdcCfupJ2+h+Ldvq0/BH1ut8Xb2zueve2B+EOr4VKD3S26QcqBRlgJUmQ8x gwUpqIZqCivLRGICGhL4d7+WM4k8mBrytL8Q/eoLI3FpqfS1SjTuvmgEtJRlCHEKBoDZ 4nJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nFipbIvL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a056a00238400b0052d586f19d5si2280157pfc.183.2022.09.02.06.42.03; Fri, 02 Sep 2022 06:42:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nFipbIvL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237921AbiIBMwU (ORCPT + 99 others); Fri, 2 Sep 2022 08:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237835AbiIBMvV (ORCPT ); Fri, 2 Sep 2022 08:51:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A92002CDDC; Fri, 2 Sep 2022 05:37:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9D1E8B82AD7; Fri, 2 Sep 2022 12:35:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECA30C433D6; Fri, 2 Sep 2022 12:35:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662122151; bh=Bs2CQBsnUjpIZ+XxHHFSiRhfkB928kkGSKMck2e8gws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nFipbIvLdvWGNnFudSU0aS7GUedmCQyE3XwtX7MhLuPX7gYNSGY08Dc4wo1+PnpKe bMEeIZacatV/jzUhMnqMy57Ojyql7gJVLz7t0K3VX9iul3p+EDgj8U3GbDWzJTFYqk 9sboJsnet0w+wnZ21ZHvhMSxB3Kwkyy/skLTY3FI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, Lee Jones , Jiri Kosina Subject: [PATCH 5.19 09/72] HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report Date: Fri, 2 Sep 2022 14:18:45 +0200 Message-Id: <20220902121405.102987587@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121404.772492078@linuxfoundation.org> References: <20220902121404.772492078@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lee Jones commit cd11d1a6114bd4bc6450ae59f6e110ec47362126 upstream. It is possible for a malicious device to forgo submitting a Feature Report. The HID Steam driver presently makes no prevision for this and de-references the 'struct hid_report' pointer obtained from the HID devices without first checking its validity. Let's change that. Cc: Jiri Kosina Cc: Benjamin Tissoires Cc: linux-input@vger.kernel.org Fixes: c164d6abf3841 ("HID: add driver for Valve Steam Controller") Signed-off-by: Lee Jones Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-steam.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/hid/hid-steam.c +++ b/drivers/hid/hid-steam.c @@ -134,6 +134,11 @@ static int steam_recv_report(struct stea int ret; r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0]; + if (!r) { + hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n"); + return -EINVAL; + } + if (hid_report_len(r) < 64) return -EINVAL; @@ -165,6 +170,11 @@ static int steam_send_report(struct stea int ret; r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0]; + if (!r) { + hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n"); + return -EINVAL; + } + if (hid_report_len(r) < 64) return -EINVAL;