Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp912589pxb; Wed, 3 Mar 2021 20:49:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJweDtTyV1rDmS3FEZB764UX3h2I5DzfKezU93T6Wi/s9GMIITZOlK7ACIhyFYZiWT1e9vqr X-Received: by 2002:a17:906:b004:: with SMTP id v4mr2284523ejy.340.1614833349038; Wed, 03 Mar 2021 20:49:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614833349; cv=none; d=google.com; s=arc-20160816; b=WpRO/Qp3ofrouusWOFuqXCpuBXH+5W5R900Ie02xRDoahWaWHf2rsa2dD5UcrHZ6Bm wzy3wWIhveMSujGIgePLG7m0AvyK/V/9kzXIOpfp87UQA3H6msuFOP6MChBL9fc2ffxY BB7NwQzQf/bL5GWFLgTtWxD/cqReGk2gpdPrmcUgIykdl64KrRm4RpoaZ1kBHmQ4gW35 tuUdKUg5Kb6XoFodcabRngiGoGGCFHCJUFM5gHvEYy/e8xh9vD6cg7dBbz+4o3Sz6cMC BzwxAnVNeg4ZXNHJoizMNScQoNxaCPywjcslZd69uJ33WqzEv68bpT93b5MgS+QF1SlV NZ5g== 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=pzgD6XxnrtPFH2rkOmDB1b66jL7lGCNsu0sGfRY44SA3elR5dpx9yRAKDUXHdQy2vf SwC+N3cElPLDEimgEf+ts5Nvx0ECCLDXEYSVCJsoBBaenMDVf9RNIJklC2DApXXRL1OA /FnLyi1wTIlfov4WjL9tIt6jt45LOs8geLX2IWaH0Rk+UoM0p44Avd7kXpVvfmtrhe1m qhy0cDP5RZ16GgWD3KDS9UGEHrqd6fmbpoTEXs8MCKB+PINEMpi/IA2T3J+OgiHcGEoK /MTUehMywb8FdMYasnWLSDKA4vsliODxLpxxZhCKm7NUaxvykV/LIiTTfHYOh2zSE3Dh Ay6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e2GXdPoj; 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 n13si970322ejs.39.2021.03.03.20.48.46; Wed, 03 Mar 2021 20:49:09 -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=e2GXdPoj; 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 S1380768AbhCBBzX (ORCPT + 99 others); Mon, 1 Mar 2021 20:55:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:48632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241950AbhCATaA (ORCPT ); Mon, 1 Mar 2021 14:30:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C6E0564E09; Mon, 1 Mar 2021 17:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619527; bh=SAfqGVoDVV7vGzd+ShP/ahMF4bUwHmopoaMbIMk9GZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e2GXdPojdwu8CEQyT7q4ijCNqiMWSrfCBiuL3Sq9VmkQzAfLzxc9nTznhkiXQcEJr HjTMrZRZDAnte9G7gMSy9k18BRDw4B0gasjyiYLCw0r2tidC5doj2CsR0xqIV9xeFt Fl5FsThBjPWdmuIMjD8uFTl8pniDeapVI/wFqXmw= 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.10 485/663] HID: wacom: Ignore attempts to overwrite the touch_max value from HID Date: Mon, 1 Mar 2021 17:12:13 +0100 Message-Id: <20210301161205.855240073@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@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; }