All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bryam Vargas via B4 Relay"
	<devnull+hexlabsecurity.proton.me@kernel.org>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH] Input: mms114 - reject an oversized device packet size
Date: Sat, 13 Jun 2026 04:31:09 +0000	[thread overview]
Message-ID: <20260613043110.1DC8E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612-b4-disp-dc4b8dc4-v1-1-d7cb0a828d92@proton.me>

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

Pre-existing issues:
- [High] Stack out-of-bounds read and severe struct misalignment when parsing MMS136/MMS134S touch events, leading to a kernel memory information leak.
--

commit 2622e1ec203d4e3a475cf8bb039715b16ecc29d8
Author: Bryam Vargas <hexlabsecurity@proton.me>

Input: mms114 - reject an oversized device packet size

This commit adds a bounds check to reject packet sizes from the device that
exceed the size of the local touch array. This prevents a stack out-of-bounds
write caused by a malfunctioning or malicious device.

Cc: stable@vger.kernel.org

> diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
> index af462086a65ca..4c75f16c503dc 100644
> --- a/drivers/input/touchscreen/mms114.c
> +++ b/drivers/input/touchscreen/mms114.c
> @@ -226,6 +226,13 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id)
>  	if (packet_size <= 0)
>  		goto out;
>  
> +	/* the device controls packet_size; reject anything too big for touch[] */
> +	if (packet_size > (int)sizeof(touch)) {
> +		dev_err(&client->dev, "Invalid packet size %d (max %zu)\n",
> +			packet_size, sizeof(touch));
> +		goto out;
> +	}
> +
>  	/* MMS136 has slightly different event size */
>  	if (data->type == TYPE_MMS134S || data->type == TYPE_MMS136)
>  		touch_size = packet_size / MMS136_EVENT_SIZE;

[Severity: High]
This is a pre-existing issue, but does this calculation cause an out-of-bounds
read and structure misalignment later in the function?

If packet_size is up to 80 (the maximum allowed by the newly added bounds
check), touch_size for MMS136 and MMS134S devices will be 80 / 6 = 13.

In the loop further down in mms114_interrupt():

    for (index = 0; index < touch_size; index++) {
        switch (touch[index].type) {

When index reaches 12, touch[12] reads 8 bytes starting from offset 96,
because sizeof(struct mms114_touch) is 8 bytes. Since the touch array is only
80 bytes long, wouldn't this read past the end of the stack buffer?

Also, since the hardware sends contiguous 6-byte events but they are iterated
using an 8-byte array step, does this misalign the parsing for every event
after the first one?

This misaligned and out-of-bounds stack data is then processed in
mms114_process_mt(), where touch->width and touch->strength are passed to
input_report_abs(). Could this inadvertently leak uninitialized stack memory to
userspace?

>  	else
>  		touch_size = packet_size / MMS114_EVENT_SIZE;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260612-b4-disp-dc4b8dc4-v1-1-d7cb0a828d92@proton.me?part=1

  reply	other threads:[~2026-06-13  4:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-13  4:21 [PATCH] Input: mms114 - reject an oversized device packet size Bryam Vargas via B4 Relay
2026-06-13  4:21 ` Bryam Vargas
2026-06-13  4:31 ` sashiko-bot [this message]
2026-06-14 21:35 ` Dmitry Torokhov

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=20260613043110.1DC8E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=devnull+hexlabsecurity.proton.me@kernel.org \
    --cc=dmitry.torokhov@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 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.