From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3BA1317158 for ; Tue, 23 Jun 2026 14:36:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782225380; cv=none; b=tujzbkVzR6mu4IrHIfZMAayESFe6LNJnmpJCnlirqAnzrtJgmMG+aj3L8TL03PLcZMEebILX0RB7DstwYaPL9u/ZCOKEooSMYMLuPl06gWMYnSGhC1yI6ebgwlN9BUtYtSBEnSO34dOydO+yZu2wU0AbyAnudvi6Avzqv6So42c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782225380; c=relaxed/simple; bh=+kq+0XwjfoBocLXoUfcbkRs6lY1uHdQ/XxAgovLfnwo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=V855Q9cXb2APSDuTa6kBeYiPnW3y8iq+/zvnEvakBEQbZ60e/9Ggcqy2LFloy7/nBeP9B4sQBSJskebvul+N3fEd2db3SxMDRXttKqmZYwACqsSKfL/N55Lr8bwVRo66ctqF24fNRBoqIOyiQnxtmXMMd+Pj7A6d+II8bB9regI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=WjRv8Ywp; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="WjRv8Ywp" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 3D02F1A088E; Tue, 23 Jun 2026 14:36:16 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0D42A601C2; Tue, 23 Jun 2026 14:36:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0E685106C81A8; Tue, 23 Jun 2026 16:36:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1782225375; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=XN/oCCtTlAUMlzvR/ND+JEuvFxFzXtyhJLOVUoMX9dg=; b=WjRv8YwpibYry8BB21VP4LUEK2UfVlRqxHc0hcVpvFQkYo4IJpdfZnX0rWJq0UokY1WtOs fmzHKydS0nK8wZcMKKKfl/T+4mSmIDyqOe4qzeXbo22i4gu4WV6CxaOyXv0G/fqhDEjUl6 sPMZZWZRNrwTKcTlVqCYy58M+saIsqeDXJqAkv6FPqjWtEC/pX0mJuF2JSUQ4qCVLBrdOf oIkR5HCBbkLFtteDeSUUrShvMdxdVFXxAeLmgwcFfGJ4t6C6NL4lEUkbRxNk6XPHbyIyWv xjKg23HnoAfGIbQhfa1cit6105OWqWWGKdZeMgopbp3QbprGbhDWWA049vommQ== From: Miquel Raynal To: Maoyi Xie Cc: Frank Li , Alexandre Belloni , linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: i3c: master: svc: IBI payload not bounded by max_payload_len In-Reply-To: <178220265899.2552261.12288525775100092849@maoyixie.com> (Maoyi Xie's message of "Tue, 23 Jun 2026 16:17:38 +0800") References: <178220265899.2552261.12288525775100092849@maoyixie.com> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Tue, 23 Jun 2026 16:36:13 +0200 Message-ID: <87mrwlmihu.fsf@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Hi, On 23/06/2026 at 16:17:38 +08, Maoyi Xie 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 payloa= d. > 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 =3D 0; > buf =3D slot->data; > while (SVC_I3C_MSTATUS_RXPEND(...) && slot->len < SVC_I3C_FIFO_SIZE) { > mdatactrl =3D readl(master->regs + SVC_I3C_MDATACTRL); > count =3D SVC_I3C_MDATACTRL_RXCOUNT(mdatactrl); > readsb(master->regs + SVC_I3C_MRDATAB, buf, count); > slot->len +=3D count; > buf +=3D count; > } > > slot->data points into the IBI pool. i3c_generic_ibi_alloc_pool() sizes e= ach > 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 s= mall > 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=C3=A8l