From: Bryam Vargas <hexlabsecurity@proton.me>
To: Andi Shyti <andi.shyti@kernel.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <bentiss@kernel.org>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Wolfram Sang <wsa@kernel.org>, itewqq <shipeiqu@sjtu.edu.cn>,
linux-i2c@vger.kernel.org, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: synaptics-rmi4 - bound the SMBus block read to the caller buffer
Date: Tue, 23 Jun 2026 07:29:45 +0000 [thread overview]
Message-ID: <20260623072935.276387-1-hexlabsecurity@proton.me> (raw)
In-Reply-To: <ajoXuK4DrgSriiww@google.com>
On 2026-06-23, Dmitry Torokhov wrote:
> Wolfram, any chance we could get this in? I am getting patches for OOB
Andi, looping you in -- MAINTAINERS hands I2C to you as of v7.1, and this is
Dmitry's 2024 i2c-core safety patch, which I just retested against current
mainline.
Dmitry, it works. You asked me to try it on the rmi_smbus stack overflow I
reported. On current mainline (master 502d801f0ab0) the patch applies with no
change after ~20 months. i2c-core-smbus.o builds, and so do the unchanged 3-arg
callers (ipmi_ssif, pmbus_core) and the 4-arg form. Nothing takes the address
of i2c_smbus_read_block_data(), so the transition macro compiles for every
caller -- each of the ~82 is a plain 3- or 4-arg call.
The concrete user that was missing in 2024: rmi_read_pdt_entry() reads a PDT
entry into an on-stack u8 buf[6], and smb_block_read() hands that buffer to
i2c_smbus_read_block_data() with no size, so a device reporting a block count
of 7..32 smashes the stack. The 4-arg form bounds it to 6:
- retval = i2c_smbus_read_block_data(client, commandcode, buf);
+ retval = i2c_smbus_read_block_data(client, commandcode, len, buf);
Why 4-arg specifically: the 3-arg default (length = I2C_SMBUS_BLOCK_MAX) is
byte-identical to today's code, so the core patch alone doesn't fix an
undersized caller -- the safety comes from moving each such caller to 4-arg,
which the rmi_smbus conversion above demonstrates.
rmi_smbus is the undersized caller here; the other block-data callers I checked
size to I2C_SMBUS_BLOCK_MAX, so this is the one live conversion for now and the
macro mainly guards the next small buffer.
I build-tested the above on mainline and A/B-verified the bound with a
userspace ASan mirror (-m64 and -m32; the unbounded value is device payload,
not bus timing, so no RMI hardware is needed): 3-arg/today faults for a count
of 7..32 into buf[6], 4-arg is clean for every count. I didn't boot-test a
patched kernel, so I'm not sending a Tested-by tag -- but happy to add one if
you want a specific config exercised.
I can post the rmi_smbus conversion as a formal patch on top of yours (it's
ready, checkpatch-clean), or you can fold it -- whichever you prefer.
Thanks,
Bryam
prev parent reply other threads:[~2026-06-23 7:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 5:39 [PATCH] Input: synaptics-rmi4 - bound the SMBus block read to the caller buffer Bryam Vargas via B4 Relay
2026-06-13 5:51 ` sashiko-bot
2026-06-23 5:22 ` Dmitry Torokhov
2026-06-23 7:29 ` Bryam Vargas [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=20260623072935.276387-1-hexlabsecurity@proton.me \
--to=hexlabsecurity@proton.me \
--cc=andi.shyti@kernel.org \
--cc=bentiss@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shipeiqu@sjtu.edu.cn \
--cc=wsa+renesas@sang-engineering.com \
--cc=wsa@kernel.org \
/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