Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhian Liang" <liangzhan5dev@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2] Input: tca8418_keypad -  Add devm cleanup to disable interrupts on unload
Date: Thu, 03 Sep 2026 21:18:03 +0000	[thread overview]
Message-ID: <20260903211804.05BF61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903210639.22472-1-liangzhan5dev@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing bounds check on hardware-provided scan code leads to an out-of-bounds read on the keymap array.
--

commit a7ecc5efa5741df5c7a115258a1df26344bc93c3
Author: Zhian Liang <liangzhan5dev@gmail.com>

Input: tca8418_keypad - Add devm cleanup to disable interrupts on unload

This patch adds a devm action during probe to clear the CFG register and
interrupt status when the device is released. This ensures interrupts are
properly disabled on probe failure and driver unbind.

> diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c
> index 4616afa0286c3..a7c7e23f16617 100644
> --- a/drivers/input/keyboard/tca8418_keypad.c
> +++ b/drivers/input/keyboard/tca8418_keypad.c

[ ... ]

While reviewing this patch, I noticed a pre-existing issue in the event
handling path:

drivers/input/keyboard/tca8418_keypad.c:tca8418_read_keypad() {
    ...
		code = MATRIX_SCAN_CODE(row, col, keypad_data->row_shift);
		input_event(input, EV_MSC, MSC_SCAN, code);
		input_report_key(input, keymap[code], state);
    ...
}

[Severity: High]
This isn't a bug introduced by this patch, but pre-existed in the codebase.

Does this code lack a bounds check on the hardware-provided scan code?

If a malfunctioning or maliciously crafted I2C device returns a large row
or column value, it appears the computed code index could exceed the
allocated keymap size. Using this index directly in input_report_key()
might lead to an out-of-bounds read on the dynamically allocated keymap
array, potentially causing a kernel panic or leaking adjacent kernel memory.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903210639.22472-1-liangzhan5dev@gmail.com?part=1

      reply	other threads:[~2026-09-03 21:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 19:29 [PATCH 1/2] Input: tca8418_keypad - Add devm cleanup to disable interrupts on unload Zhian Liang
2026-09-03 19:29 ` [PATCH 2/2] Input: tca8418_keypad - fix race condition in interrupt handler Zhian Liang
2026-09-03 19:41   ` sashiko-bot
2026-09-03 20:38     ` Zhian Liang
2026-09-03 19:42 ` [PATCH 1/2] Input: tca8418_keypad - Add devm cleanup to disable interrupts on unload sashiko-bot
2026-09-03 21:06 ` [PATCH v2] " Zhian Liang
2026-09-03 21:18   ` sashiko-bot [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=20260903211804.05BF61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=liangzhan5dev@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox