From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Maoyi Xie <maoyixie.tju@gmail.com>
Cc: Frank Li <Frank.Li@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: i3c: master: svc: IBI payload not bounded by max_payload_len
Date: Tue, 23 Jun 2026 16:36:13 +0200 [thread overview]
Message-ID: <87mrwlmihu.fsf@bootlin.com> (raw)
In-Reply-To: <178220265899.2552261.12288525775100092849@maoyixie.com> (Maoyi Xie's message of "Tue, 23 Jun 2026 16:17:38 +0800")
Hi,
On 23/06/2026 at 16:17:38 +08, Maoyi Xie <maoyixie.tju@gmail.com> wrote:
> Hi all,
>
> I think svc_i3c_master_handle_ibi() in drivers/i3c/master/svc-i3c-master.c
> can write past the IBI slot buffer when a device sends a large IBI payload.
> I would appreciate it if you could let me know whether you agree.
>
> The read loop bounds the slot only by the hardware FIFO size, not by the
> requested max_payload_len.
>
> slot->len = 0;
> buf = slot->data;
> while (SVC_I3C_MSTATUS_RXPEND(...) && slot->len < SVC_I3C_FIFO_SIZE) {
> mdatactrl = readl(master->regs + SVC_I3C_MDATACTRL);
> count = SVC_I3C_MDATACTRL_RXCOUNT(mdatactrl);
> readsb(master->regs + SVC_I3C_MRDATAB, buf, count);
> slot->len += count;
> buf += count;
> }
>
> slot->data points into the IBI pool. i3c_generic_ibi_alloc_pool() sizes each
> slot at max_payload_len. svc_i3c_master_request_ibi() only rejects a
> max_payload_len above SVC_I3C_FIFO_SIZE (16). So a driver can ask for a small
> window, and mctp-i3c asks for 1. count comes from the controller RXCOUNT
> field and can be up to 31. The loop stops at SVC_I3C_FIFO_SIZE, not at the
> window. A device that sends more bytes than the window overruns slot->data
> into the pool.
It is indeed possible. Please send a patch!
Thanks,
Miquèl
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Maoyi Xie <maoyixie.tju@gmail.com>
Cc: Frank Li <Frank.Li@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: i3c: master: svc: IBI payload not bounded by max_payload_len
Date: Tue, 23 Jun 2026 16:36:13 +0200 [thread overview]
Message-ID: <87mrwlmihu.fsf@bootlin.com> (raw)
In-Reply-To: <178220265899.2552261.12288525775100092849@maoyixie.com> (Maoyi Xie's message of "Tue, 23 Jun 2026 16:17:38 +0800")
Hi,
On 23/06/2026 at 16:17:38 +08, Maoyi Xie <maoyixie.tju@gmail.com> wrote:
> Hi all,
>
> I think svc_i3c_master_handle_ibi() in drivers/i3c/master/svc-i3c-master.c
> can write past the IBI slot buffer when a device sends a large IBI payload.
> I would appreciate it if you could let me know whether you agree.
>
> The read loop bounds the slot only by the hardware FIFO size, not by the
> requested max_payload_len.
>
> slot->len = 0;
> buf = slot->data;
> while (SVC_I3C_MSTATUS_RXPEND(...) && slot->len < SVC_I3C_FIFO_SIZE) {
> mdatactrl = readl(master->regs + SVC_I3C_MDATACTRL);
> count = SVC_I3C_MDATACTRL_RXCOUNT(mdatactrl);
> readsb(master->regs + SVC_I3C_MRDATAB, buf, count);
> slot->len += count;
> buf += count;
> }
>
> slot->data points into the IBI pool. i3c_generic_ibi_alloc_pool() sizes each
> slot at max_payload_len. svc_i3c_master_request_ibi() only rejects a
> max_payload_len above SVC_I3C_FIFO_SIZE (16). So a driver can ask for a small
> window, and mctp-i3c asks for 1. count comes from the controller RXCOUNT
> field and can be up to 31. The loop stops at SVC_I3C_FIFO_SIZE, not at the
> window. A device that sends more bytes than the window overruns slot->data
> into the pool.
It is indeed possible. Please send a patch!
Thanks,
Miquèl
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next prev parent reply other threads:[~2026-06-23 14:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 8:17 i3c: master: svc: IBI payload not bounded by max_payload_len Maoyi Xie
2026-06-23 8:17 ` Maoyi Xie
2026-06-23 14:36 ` Miquel Raynal [this message]
2026-06-23 14:36 ` Miquel Raynal
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=87mrwlmihu.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=Frank.Li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maoyixie.tju@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 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.