Linux Input/HID development
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Chengyu Liu <lui2012qwq@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH 0/2] Input: clamp SMBus block reads to the caller's buffer
Date: Tue, 3 Nov 2026 10:48:31 -0800	[thread overview]
Message-ID: <auosSLHRu2mcuO6e@google.com> (raw)
In-Reply-To: <20261103131127.1585884-1-lui2012qwq@gmail.com>

Hi Chengyu,

On Tue, Nov 03, 2026 at 09:11:25PM +0800, Chengyu Liu wrote:
> i2c_smbus_read_block_data() has no length parameter: it copies the
> device-reported byte count (clamped to I2C_SMBUS_BLOCK_MAX by the
> core) into the caller's buffer, so callers must pass a full-size
> buffer.  An audit of all call sites found two input drivers passing
> smaller stack buffers:
> 
>  - rmi4: rmi_read_pdt_entry() reads PDT entries into a 6-byte stack
>    buffer during PDT scanning at probe time; a device reporting a
>    count of 32 overruns it by 26 bytes.
> 
>  - cyapa: cyapa_gen3_irq_handler() reads into a 27-byte struct
>    cyapa_reg_data on every touch interrupt; a count of 32 overruns it
>    by 5 bytes, in interrupt context.
> 
> In both cases the contents are controlled by the device.  Bounce the
> reads through a full-size buffer and clamp the copy to the requested
> length.

No, we should be using the new 4-argument variant of 
i2c_smbus_read_block_data() that I posted earlier.

Thanks.

-- 
Dmitry

      parent reply	other threads:[~2026-11-03 18:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 13:11 [PATCH 0/2] Input: clamp SMBus block reads to the caller's buffer Chengyu Liu
2026-11-03 13:11 ` [PATCH 1/2] Input: rmi4 - clamp SMBus block reads to the requested length Chengyu Liu
2026-11-03 13:11 ` [PATCH 2/2] Input: cyapa - clamp SMBus block reads to the caller's buffer Chengyu Liu
2026-11-03 13:22   ` sashiko-bot
2026-11-03 14:10     ` cy l
2026-11-03 18:48 ` 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=auosSLHRu2mcuO6e@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=lui2012qwq@gmail.com \
    /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