All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Brent Roman <brent@mbari.org>
Subject: Re: [PATCH] HID: input: set usage type to key on keycode remap
Date: Sat, 6 Nov 2021 19:16:57 -0700	[thread overview]
Message-ID: <YYc3GYKgfKDQ0AYj@google.com> (raw)
In-Reply-To: <20211028205542.499280-1-linux@weissschuh.net>

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 <brent@mbari.org>
> Tested-by: Brent Roman <brent@mbari.org>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

Makes sense.

Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> ---
>  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

      reply	other threads:[~2021-11-07  2:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 20:55 [PATCH] HID: input: set usage type to key on keycode remap Thomas Weißschuh
2021-11-07  2:16 ` Dmitry Torokhov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YYc3GYKgfKDQ0AYj@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=brent@mbari.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.