Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ayush Singh" <ayush@beagleboard.org>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
	ojeda@kernel.org
Subject: Re: [PATCH 1/7] greybus: connection: Export gb_connection_get() and gb_connection_put()
Date: Thu, 20 Aug 2026 09:41:42 +0000	[thread overview]
Message-ID: <20260820094142.BBCEF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260820-gb-uart-transport-v1-1-282da14ab7b7@beagleboard.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Exporting `gb_connection_get/put` allows connections to outlive their parent objects, causing a Use-After-Free in tracepoints.
--

--- Patch [1]: [PATCH 1/7] greybus: connection: Export gb_connection_get() and gb_connection_put() ---
commit d7d6f3dcc2daeb414806a0f2b9dbabd440f8ec1e
Author: Ayush Singh <ayush@beagleboard.org>

greybus: connection: Export gb_connection_get() and gb_connection_put()

This commit exports gb_connection_get() and gb_connection_put() to allow
modular drivers to manage connection references. It changes them to non-static
and adds EXPORT_SYMBOL_GPL declarations.

> diff --git a/drivers/greybus/connection.c b/drivers/greybus/connection.c
> index bd04485decb3d..f8fda22bc4667 100644
> --- a/drivers/greybus/connection.c
> +++ b/drivers/greybus/connection.c

[ ... ]

> -static void gb_connection_get(struct gb_connection *connection)
> +void gb_connection_get(struct gb_connection *connection)
>  {
>  	kref_get(&connection->kref);
>  
>  	trace_gb_connection_get(connection);
>  }
> +EXPORT_SYMBOL_GPL(gb_connection_get);
>  
> -static void gb_connection_put(struct gb_connection *connection)
> +void gb_connection_put(struct gb_connection *connection)
>  {
>  	trace_gb_connection_put(connection);
>  
>  	kref_put(&connection->kref, gb_connection_kref_release);
>  }
> +EXPORT_SYMBOL_GPL(gb_connection_put);

[Severity: High]
Does exporting this function introduce a regression where a connection can
outlive its parent host device or bundle, potentially causing a use-after-free
in the tracepoints?

If an external module caches a connection reference and drops it asynchronously
after the Greybus core has torn down and freed the gb_bundle and
gb_host_device, calling gb_connection_put() will trigger
trace_gb_connection_put() and potentially trace_gb_connection_release().

These trace events rely on a shared TP_fast_assign block in
drivers/greybus/greybus_trace.h that unconditionally dereferences the parent
objects:

drivers/greybus/greybus_trace.h:gb_connection() {
    TP_fast_assign(
        __entry->hd_bus_id = connection->hd->bus_id;
        __entry->bundle_id = connection->bundle ?
                connection->bundle->id : BUNDLE_ID_NONE;
    ...
}

If the parent hd or bundle has already been freed, will these tracepoints
dereference freed memory?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260820-gb-uart-transport-v1-0-282da14ab7b7@beagleboard.org?part=1

  reply	other threads:[~2026-08-20  9:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20  9:25 [PATCH 0/7] Add Greybus Sotfsvc and UART Node drivers Ayush Singh
2026-08-20  9:25 ` [PATCH 1/7] greybus: connection: Export gb_connection_get() and gb_connection_put() Ayush Singh
2026-08-20  9:41   ` sashiko-bot [this message]
2026-08-20  9:25 ` [PATCH 2/7] greybus: connection: Add gb_connection_hd_find_by_intf() Ayush Singh
2026-08-20  9:32   ` sashiko-bot
2026-08-20  9:25 ` [PATCH 3/7] rust: crc_ccitt: add CRC-CCITT abstraction Ayush Singh
2026-08-20  9:33   ` sashiko-bot
2026-08-20  9:25 ` [PATCH 4/7] rust: kernel: Add greybus abstractions Ayush Singh
2026-08-20  9:42   ` sashiko-bot
2026-08-20  9:25 ` [PATCH 5/7] drivers: greybus: Add software SVC implementation Ayush Singh
2026-08-20  9:40   ` sashiko-bot
2026-08-20  9:25 ` [PATCH 6/7] greybus: Add Rust UART node driver Ayush Singh
2026-08-20  9:38   ` sashiko-bot
2026-08-20  9:25 ` [PATCH 7/7] dt-bindings: beagle: Add BeagleConnect Freedom Ayush Singh
2026-08-20  9:31   ` sashiko-bot

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=20260820094142.BBCEF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ayush@beagleboard.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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