Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp468413pxb; Wed, 3 Mar 2021 07:40:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQDzjKeAeMUJJqG4r2Z+3XE720P9ey3p0E33LKs0cgsevQynPUiYeZ5pRia0Wrwe+g92ug X-Received: by 2002:aa7:dd99:: with SMTP id g25mr14883961edv.230.1614786038633; Wed, 03 Mar 2021 07:40:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614786038; cv=none; d=google.com; s=arc-20160816; b=ca3rB77XGpLXluBA407Lfl6uLqgsftDi74RzTmZZ3J4G6aQHesV9oHAmLEr+6JNby+ eXl0/L7QkSPNe49nnEZ2eVliZOuZKtR40HlU0K1aF/7LaLS6rgEIXeB0ujyj/jFqB1hW A3peJV9TzyYIbxrRY80HoTpn1Ycvzhy8ckrGRxCc7NRBv9pQzlniSTtLEHxJPP2I4jyi 89Tzarj3dAUrvH3NmzquUiWvfebAxqXP9qTpoz+5oQ9V57hmeEqgV1yRSBP2RTPnCoHq eBsLMsD9xSngKKEjRopcCCJ/QCABcBvuL4M6IptHu94i/qsvEqv5/SU8xAaM8qGt0pIs 7d2g== 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=8BgkPaQm3OcGaCYPxqMWyUWAahBHqDF4/blKkAXYjS0=; b=NLTQkZcSgQvpuCC5SxhCjyrkWxanthRhtSfRZg6Lu1a/lHXhxNFJXU2zm9QIoZq+CE +mjAPrre0qKVsAOf+iMxO2EVeMh7ryP7C5ue2xR1pg4p0qVWhwJy7NAWrk/TdxZWML4q NhZWNXchs9QDFSiMN+/EwT/hUqr9BvfVWJyPtQpXRG+L2MDHbHFfSYu6uS28QQ8uBOlC nqdj950duWtCwW5fYZeAIAY03Rk/+HKrPQhXp0+mSaQ5Nps0qJDzxHDdMJDp8S2DTB9u w2DFf2Zlmqraq09ZQJlVe7H+YQt8xv38Z8zlWLIsqcDg/w3FBCbts+oAJVhiTXEzgJ4y b6zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TtxgmCwJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si7798332ejv.120.2021.03.03.07.39.47; Wed, 03 Mar 2021 07:40:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TtxgmCwJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1343770AbhCAWhp (ORCPT + 99 others); Mon, 1 Mar 2021 17:37:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:33918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231443AbhCARoj (ORCPT ); Mon, 1 Mar 2021 12:44:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8AE08650D5; Mon, 1 Mar 2021 16:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617907; bh=SAfqGVoDVV7vGzd+ShP/ahMF4bUwHmopoaMbIMk9GZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TtxgmCwJuhBC3FqGR9QucI1KVZtvDfb/5nfPUXfR+Jn8wDP+8DcBejsylmiaGibGF bLE7STwA8/tRU/J+BnQy2qkqcqeRfqB0YE6MROqZNdXbQ2VR0+D8EqPAATkG3Z4ODp s/QjyDkDzNgNniunv7hlsyL5KFEjUOu44iSseGsQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gerecke , Jiri Kosina Subject: [PATCH 5.4 239/340] HID: wacom: Ignore attempts to overwrite the touch_max value from HID Date: Mon, 1 Mar 2021 17:13:03 +0100 Message-Id: <20210301161100.055680765@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161048.294656001@linuxfoundation.org> References: <20210301161048.294656001@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Gerecke commit 88f38846bfb1a452a3d47e38aeab20a4ceb74294 upstream. The `wacom_feature_mapping` function is careful to only set the the touch_max value a single time, but this care does not extend to the `wacom_wac_finger_event` function. In particular, if a device sends multiple HID_DG_CONTACTMAX items in a single feature report, the driver will end up retaining the value of last item. The HID descriptor for the Cintiq Companion 2 does exactly this. It incorrectly sets a "Report Count" of 2, which will cause the driver to process two HID_DG_CONTACTCOUNT items. The first item has the actual count, while the second item should have been declared as a constant zero. The constant zero is the value the driver ends up using, however, since it is the last HID_DG_CONTACTCOUNT in the report. Report ID (16), Usage (Contact Count Maximum), ; Contact count maximum (55h, static value) Report Count (2), Logical Maximum (10), Feature (Variable), To address this, we add a check that the touch_max is not already set within the `wacom_wac_finger_event` function that processes the HID_DG_TOUCHMAX item. We emit a warning if the value is set and ignore the updated value. This could potentially cause problems if there is a tablet which has a similar issue but requires the last item to be used. This is unlikely, however, since it would have to have a different non-zero value for HID_DG_CONTACTMAX earlier in the same report, which makes no sense except in the case of a firmware bug. Note that cases where the HID_DG_CONTACTMAX items are in different reports is already handled (and similarly ignored) by `wacom_feature_mapping` as mentioned above. Link: https://github.com/linuxwacom/input-wacom/issues/223 Fixes: 184eccd40389 ("HID: wacom: generic: read HID_DG_CONTACTMAX from any feature report") Signed-off-by: Jason Gerecke CC: stable@vger.kernel.org Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/wacom_wac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2600,7 +2600,12 @@ static void wacom_wac_finger_event(struc wacom_wac->is_invalid_bt_frame = !value; return; case HID_DG_CONTACTMAX: - features->touch_max = value; + if (!features->touch_max) { + features->touch_max = value; + } else { + hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max " + "%d -> %d\n", __func__, features->touch_max, value); + } return; }