Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5167390pxb; Sun, 7 Nov 2021 06:34:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwp8EHJJzkbOmzKcMh0aKtIAJWe1uIgQFC9KL2uU3km28ghJx0e/9fIY8LrMcQfJrTvMhsQ X-Received: by 2002:a05:6402:3493:: with SMTP id v19mr39817271edc.149.1636295668441; Sun, 07 Nov 2021 06:34:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636295668; cv=none; d=google.com; s=arc-20160816; b=NXkWy8y8tk5iF/Dv61veWFjhJFN2YTxKal/AtTK/n+0/NQ01/3hYIomyhWsfv5KElr K31pGvMv5wStExg+0mkZ4VzXNvixPaK8ou+W+TLltM6FIJRQx69Paj+jtSAlbEVAT/Yc 8ezOY/+NoaQwPXMae35rMCBsbnaGb9PMWMkicCLEVy3h0diwawguaJ5EFGTzl1lawaKt A9HGorEynY6kgPE6GF9Mes1NZB70R9lRUYda1bAmaqLK5J96ie5ipMcTMXhKEtT5XtbK vmVJ6TZDXc9rPmBo26gWVKLm5wWL5RzkK9AtyqPPt+R+Sy/Td73cjK6OwVEQH7Q6Osdf A6Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gg2o6Jpi3G1bwmp5OBY9g1sVftj0DmiTSSSqsnFCp9I=; b=Mh1+Hh8ko0AGnTbGZzuHoaw46Nrc8F79I77+Tkdb0nIWldcnA22UKo36J+Bsyba27f 6Jmt4MesZNemA0GKnPCO5UpfX1Mu7U9Go5uAqzusGA1jabsDNnv5QnlSDUGijO/HtX54 OT9DZZucSOUyQAJX6sxyUj7ptCScPaAADDep7t9wwfYH4iGBlDFxBvcpsS+BSxMMSfcV GST9lOpgkbobHFRuwmQF4H6hb4ATYwAz4VAkRe7E0Cd5u002yxaCFsPE9Pnhf3Hk0rxG Ll/SclWAU9X+2N9DwpcC/Gs6WU8rFC3fFt2enaDMI3r8vjiyQ9d/f7z7PrjePuGP3aro 7hSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nt+Wohtf; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si24990633edd.232.2021.11.07.06.33.52; Sun, 07 Nov 2021 06:34:28 -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=@gmail.com header.s=20210112 header.b=nt+Wohtf; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234035AbhKGCTr (ORCPT + 99 others); Sat, 6 Nov 2021 22:19:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233960AbhKGCTn (ORCPT ); Sat, 6 Nov 2021 22:19:43 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D5A4C061570; Sat, 6 Nov 2021 19:17:02 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id g184so11818113pgc.6; Sat, 06 Nov 2021 19:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=gg2o6Jpi3G1bwmp5OBY9g1sVftj0DmiTSSSqsnFCp9I=; b=nt+WohtfbSOXNAReHWLuxuTkhwvbBVXUBM6dCuqc/GZBBq9XAijH5X5lJZXz68ks2A 9g4lJeLquYBfoSFwtYog5k0ZBJmzmPsooSpQUsGBHtcQIDRe/Qb+cOYF8JWAZUtRsZjt gCVIYZHpOPg5Nn2jlT/xGyJqOvvGazH8b0q6tSYhSQTC9RRMec5ZlMmdNSM019SfFbLI KgssZsJTGM8H7nFG45TcpVBkUwRQTK6FKl8GJUm16PWmdidI4YsrmrIMtp+d6nMrgIxj qwIlumYPjDlGgLmzKeZF1DdASdoSh2cvCAl51z5rzsbT9B541WUXL7su99cScPHseXtZ boIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=gg2o6Jpi3G1bwmp5OBY9g1sVftj0DmiTSSSqsnFCp9I=; b=NPEOIWdhq2eL5EVOuhtSpr3x83TGNB6ynfJW7iDu5qYoQp04GhKiChDwHH4koj9EOa 512FFoI1MNu2YT0AwiB2q99KaqWLmjCeBJTNHQ4w0tUNS8MDbCNYYB9VXKR2XzZajz8z rlx/CaqLom6VzS8LN2H5kG2gQ6qpXi7MYMJDs01/YBxe8TLlogFMQPMP+8bNA+gi//1v YTYAvZrGNqDvUiTINjbS7RIbyk22srLFIiyaXM29c9FEErTV3CKkAxc/PRTcJCfhjDt4 5k/cLCEYMoPWjBIToqzFGDAQvkbhFxbAkNkJUcSvIqeQ+E59Rr2vPPOTKYmw8HLiQ1F3 qjzg== X-Gm-Message-State: AOAM531F/HluKYOJevPWiOPmayvKCxeSw49OPihnmOuPtIjv63vj10uR Tl8Q+74Nc5V0XCNvwXIzYNY= X-Received: by 2002:a65:460f:: with SMTP id v15mr17547110pgq.430.1636251420719; Sat, 06 Nov 2021 19:17:00 -0700 (PDT) Received: from google.com ([2620:15c:202:201:53c2:e6fc:3a1a:b644]) by smtp.gmail.com with ESMTPSA id s15sm4706443pjs.51.2021.11.06.19.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Nov 2021 19:16:59 -0700 (PDT) Date: Sat, 6 Nov 2021 19:16:57 -0700 From: Dmitry Torokhov To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Brent Roman Subject: Re: [PATCH] HID: input: set usage type to key on keycode remap Message-ID: References: <20211028205542.499280-1-linux@weissschuh.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20211028205542.499280-1-linux@weissschuh.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 28, 2021 at 10:55:42PM +0200, Thomas Wei?schuh wrote: > When a scancode is manually remapped that previously was not handled as > key, then the old usage type was incorrectly reused. > > This caused issues on a "04b3:301b IBM Corp. SK-8815 Keyboard" which has > marked some of its keys with an invalid HID usage. These invalid usage > keys are being ignored since support for USB programmable buttons was > added. > > The scancodes are however remapped explicitly by the systemd hwdb to the > keycodes that are printed on the physical buttons. During this mapping > step the existing usage is retrieved which will be found with a default > type of 0 (EV_SYN) instead of EV_KEY. > > The events with the correct code but EV_SYN type are not forwarded to > userspace. > > This also leads to a kernel oops when trying to print the report descriptor > via debugfs. hid_resolv_event() tries to resolve a EV_SYN event with an > EV_KEY code which leads to an out-of-bounds access in the EV_SYN names > array. > > Fixes: bcfa8d1457 ("HID: input: Add support for Programmable Buttons") > Fixes: f5854fad39 ("Input: hid-input - allow mapping unknown usages") > Reported-by: Brent Roman > Tested-by: Brent Roman > Signed-off-by: Thomas Wei?schuh Makes sense. Reviewed-by: Dmitry Torokhov > --- > drivers/hid/hid-input.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c > index 4b5ebeacd283..21d8cc64064d 100644 > --- a/drivers/hid/hid-input.c > +++ b/drivers/hid/hid-input.c > @@ -160,6 +160,7 @@ static int hidinput_setkeycode(struct input_dev *dev, > if (usage) { > *old_keycode = usage->type == EV_KEY ? > usage->code : KEY_RESERVED; > + usage->type = EV_KEY; > usage->code = ke->keycode; > > clear_bit(*old_keycode, dev->keybit); > > base-commit: 42d43c92fc577dca59ed74aec7868abec8d6ca6e > -- > 2.33.1 > Thanks. -- Dmitry