From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: bleung@chromium.org, dawidn@google.com,
chrome-platform@lists.linux.dev, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] lib: Add ref_proxy module
Date: Fri, 15 Aug 2025 05:35:46 +0000 [thread overview]
Message-ID: <aJ7HMvh14kQsHjh-@google.com> (raw)
In-Reply-To: <2025081408-fracture-happening-dda6@gregkh>
On Thu, Aug 14, 2025 at 12:03:11PM +0200, Greg KH wrote:
> On Thu, Aug 14, 2025 at 09:10:18AM +0000, Tzung-Bi Shih wrote:
> > +/**
> > + * devm_ref_proxy_provider_alloc() - Dev-managed ref_proxy_provider_alloc().
> > + * @dev: The device.
> > + * @ref: The pointer of resource.
> > + *
> > + * This holds an initial refcount to the struct.
> > + *
> > + * Return: The pointer of struct ref_proxy_provider. NULL on errors.
> > + */
> > +struct ref_proxy_provider *devm_ref_proxy_provider_alloc(struct device *dev,
> > + void *ref)
> > +{
> > + struct ref_proxy_provider *rpp;
> > +
> > + rpp = ref_proxy_provider_alloc(ref);
> > + if (rpp)
> > + if (devm_add_action_or_reset(dev, devm_ref_proxy_provider_free,
> > + rpp))
> > + return NULL;
> > +
> > + return rpp;
> > +}
> > +EXPORT_SYMBOL(devm_ref_proxy_provider_alloc);
>
> Do we really need a devm version? That feels odd as this should be
> doing almost the same thing that devm does, right? How do they interact
> properly?
ref_proxy is similar to devm. The key difference is their lifetime: a
devm resource is freed when the device detaches, whereas a
ref_proxy_provider persists as long as it has references from ref_proxy.
Since the resource in my use case is provided by the device, it's more
intuitive to tie the resource's lifetime to the device's.
This devm helper further simplifies the provider code. Otherwise, the
provider needs to call ref_proxy_provider_free() at its error handling
paths or device .remove() callback.
> And do you have a selftest for this thing anywhere?
Will address all review comments and add tests using kselftest and/or KUnit
in the next version.
next prev parent reply other threads:[~2025-08-15 5:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 9:10 [PATCH 0/3] platform/chrome: Fix a possible UAF via ref_proxy Tzung-Bi Shih
2025-08-14 9:10 ` [PATCH 1/3] lib: Add ref_proxy module Tzung-Bi Shih
2025-08-14 10:03 ` Greg KH
2025-08-15 5:35 ` Tzung-Bi Shih [this message]
2025-08-14 10:05 ` Greg KH
2025-08-14 10:27 ` Danilo Krummrich
2025-08-14 10:55 ` Danilo Krummrich
2025-08-15 5:36 ` Tzung-Bi Shih
2025-08-14 9:10 ` [PATCH 2/3] platform/chrome: Protect cros_ec_device lifecycle with ref_proxy Tzung-Bi Shih
2025-08-15 13:37 ` kernel test robot
2025-08-14 9:10 ` [PATCH 3/3] platform/chrome: cros_ec_chardev: Consume cros_ec_device via ref_proxy Tzung-Bi Shih
2025-08-15 21:06 ` kernel test robot
2025-08-16 11:46 ` kernel test robot
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=aJ7HMvh14kQsHjh-@google.com \
--to=tzungbi@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dawidn@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.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