From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381561; b=QBZGblhAA6VmBmOB3v5W1KAZ1F4QozoNaOdgqUnxnDGRugcC9UgC+g7HJ1w7lpv4v9mD hSkSUk8R0IiKTkOCLLD/tLdi0dNV8Bv2biphA2Ee75u3G/3n2sy2GUTrkw2N385UiWX2V 7TDOIjqPkjvoS8D8wM+mtKKLqIcAThYIWhtQjXwdduwpfj22XiarVrci3j6To6/M46CeK oKM5PbP1D+5BBXTsdkNeDFpQ0fJQQSpKqIC7Kq+L/0EPzYw+hmlqaiKbP29CZHvUsUMtw m1eEVnAMR1DB1WlEAmtq32dyiMYePgWOM6FeTLNwQb7iXdZ+xEvvp6JFEKYDX98Ad5w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381561; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=eMEKKU2MZPusXUN8P6c4s9wWNt1TjwGo3t4QLdPxr2I=; b=y0tNeXWLnMYvz3jQVV6in1oQ8C5oAN5Ipbeh7oiCOgq/sbXhUimAJwNxMlrXB8Id6en6 CcY/y+4ivw/qmHP/zvWKzjYY7PX5vr1aM4wRO8TA0CygGOhQBSyjuDHgUrmAElzVDG5+c jAYpaHeNRCXayOEnF021mMZ0YyLNXijtOrPa8xMzaG+QV680yNHx0KAp4BC8YYAAP+P3f KNUiGFjQaANtmICboijp1OCoIJOAWWOWJSUAkMcuUKeflEgWDUw8UMfKFRsxYYhLmmURy bMyMgkK8yJIapbUJBJx/juvKPR+Tynx6lViGwJ5TQDWiTja+H1+rVXC9G/fuoCqgZxg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CNoyUfge; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE9F4606A322; Fri, 4 Dec 2026 10:52:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CNoyUfge Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EF531F000CE; Fri, 4 Dec 2026 10:52:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796381561; bh=eMEKKU2MZPusXUN8P6c4s9wWNt1TjwGo3t4QLdPxr2I=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=CNoyUfgefSxZ0lhzZ4yqgewNThZQ7gTLrbLZPYGylBWsmOsW/12gXV6teI0d4i91M b3EvrW6g7gfOs++mDyV+MYimzk1hhjdujISsgJCNTO7utHzNYPQ44/Ng5qh0Y/Vusk yuaoCsb05cIPtK8eOKAUI69HIkBJZz/N03klXnIqcyEerABYOjzWoF607vzQ/hMFBj hgI908aXpD7ITMRFF1xDU+8FwnK7n+TMeuIMtWVJJCuRLptDyn/tabU+XBiq4w/qeQ 662gljvvrFdQ1H0jN02tDAmfOT17HogDdCi4RPWnqnqhiPkA5aRPpRw06d8zLvtvXY lowurEV9t3SeA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 4/9] greybus: connection: Add greybus_data_rcvd_by_intf() Reply-To: sashiko-reviews@lists.linux.dev To: "Ayush Singh" , "Jason Kridner" , robertcnelson@gmail.com, "Johan Hovold" , "Alex Elder" , "Greg Kroah-Hartman" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?b?Qmo=?= =?utf-8?b?w7ZybiBSb3kgQmFyb24=?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Danilo Krummrich" , "Daniel Almeida" , "Tamir Duberstein" , "Alexandre Courbot" , =?utf-8?b?T251ciDDlnprYW4=?= , "Eric Biggers" , "Ard Biesheuvel" , "Ayush Singh" , "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "Lorenzo Stoakes" , "Vlastimil Babka" , "Liam R. Howlett" , "Uladzislau Rezki" , "Markus Probst" Cc: linux-crypto@vger.kernel.org, devicetree@vger.kernel.org In-Reply-To: <20261204-gb-uart-transport-v6-4-668b333ae71d@beagleboard.org> References: <20261204-gb-uart-transport-v6-0-668b333ae71d@beagleboard.org> <20261204-gb-uart-transport-v6-4-668b333ae71d@beagleboard.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 10:52:39 +0000 X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] greybus: UAF of connection->intf in gb_connection_hd_find_by_intf() - [Low] greybus: inaccurate SVC rationale for new greybus_data_rcvd_by_intf() API -- commit 9a7e831befd1a2fc164cd72fa192fea985fd34bd Author: Ayush Singh greybus: connection: Add greybus_data_rcvd_by_intf() This commit adds gb_connection_hd_find_by_intf() and exports greybus_data_rcvd_by_intf() to deliver incoming Greybus data by interface id and interface CPort id instead of host CPort id. > diff --git a/drivers/greybus/connection.c b/drivers/greybus/connection.c > index bd04485decb3d..ce8646299ce8c 100644 > --- a/drivers/greybus/connection.c > +++ b/drivers/greybus/connection.c > @@ -69,6 +69,32 @@ gb_connection_hd_find(struct gb_host_device *hd, u16 c= port_id) > return connection; > } > =20 > +/* > + * Returns a reference-counted pointer to the connection if found. > + */ > +static struct gb_connection * > +gb_connection_hd_find_by_intf(struct gb_host_device *hd, u8 intf_id, > + u16 intf_cport) > +{ > + struct gb_connection *connection; > + unsigned long flags; > + > + spin_lock_irqsave(&gb_connections_lock, flags); > + list_for_each_entry(connection, &hd->connections, hd_links) { > + if (connection->intf && > + connection->intf->interface_id =3D=3D intf_id && > + connection->intf_cport_id =3D=3D intf_cport) { [Severity: High] Can dereferencing connection->intf->interface_id trigger a use-after-free of struct gb_interface? Neither _gb_connection_create() nor gb_control_create() takes a reference on intf->dev, and control->connection is only unlinked from hd->connections in gb_control_release(). During module removal, gb_control_del() drops control->dev's parent reference to intf->dev via device_del(). If a bus or PM iterator still holds control->dev (or CONFIG_DEBUG_KOBJECT_RELEASE delays release), gb_interface_release() can free intf while control->connection stays listed: CPU0 CPU1 gb_interface_disable() gb_control_del() device_del(&control->dev) put_device(&intf->dev) gb_control_put() [held by bus/PM] gb_interface_release() kfree(intf) greybus_data_rcvd_by_intf() gb_connection_hd_find_by_intf() connection->intf->interface_id <-- use-after-free Any incoming frame on the shared host device then reads freed memory under gb_connections_lock with IRQs disabled. Caching interface_id in struct gb_connection at creation time (or holding a reference on intf->dev for the connection's lifetime) would avoid dereferencing a freed gb_interface. [ ... ] > @@ -91,6 +117,27 @@ void greybus_data_rcvd(struct gb_host_device *hd, u16= cport_id, > } > EXPORT_SYMBOL_GPL(greybus_data_rcvd); > =20 > +/* > + * Callback from a host driver that only knows the remote end of a conne= ction > + * (interface id and interface CPort id), such as a software SVC. > + */ > +int greybus_data_rcvd_by_intf(struct gb_host_device *hd, u8 intf_id, > + u16 intf_cport, u8 *data, size_t length) [Severity: Low] Is this new exported RX entry point needed for a software SVC, and is the rationale in the comment and commit message accurate? For every non-static connection, gb_connection_svc_connection_create() sends both hd_cport_id and (interface_id, intf_cport_id) to the SVC via GB_SVC_TYPE_CONN_CREATE, and gb_connection_svc_connection_destroy() pairs it with GB_SVC_TYPE_CONN_DESTROY. On TX, gb_message_send() also passes hd_cport_id to message_send(). A software SVC that tracks its connection table can deliver data through the existing greybus_data_rcvd() instead of adding a duplicate exported helper. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-gb-uart-tr= ansport-v6-0-668b333ae71d@beagleboard.org?part=3D4