lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aIZYRJQNaNTXE3Cm@kekkonen.localdomain>
Date: Sun, 27 Jul 2025 16:48:04 +0000
From: "sakari.ailus@...ux.intel.com" <sakari.ailus@...ux.intel.com>
To: Tarang Raval <tarang.raval@...iconsignals.io>
Cc: Laurent Pinchart <laurent.pinchart@...asonboard.com>,
	"hverkuil@...all.nl" <hverkuil@...all.nl>,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Ricardo Ribalda <ribalda@...omium.org>,
	Hans de Goede <hansg@...nel.org>,
	James Cowgill <james.cowgill@...ize.com>,
	Yunke Cao <yunkec@...gle.com>,
	Tomi Valkeinen <tomi.valkeinen@...asonboard.com>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
	Tommaso Merciai <tomm.merciai@...il.com>,
	"linux-media@...r.kernel.org" <linux-media@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 0/4] media: Add devm-managed helper functions for media
 and V4L2 subsystems

Hi Tarang,

Thanks for the patchset.

On Wed, Jul 23, 2025 at 02:08:03PM +0000, Tarang Raval wrote:
> Hi Laurent,
> 
> > On Wed, Jul 23, 2025 at 03:55:04PM +0530, Tarang Raval wrote:
> > > This patch series introduces devm-managed versions of several commonly used
> > > media and V4L2 initialization functions. These helpers simplify resource
> > > management by leveraging the devres infrastructure, ensuring automatic
> > > cleanup when the associated device is detached or the driver is unloaded.
> > 
> > I'll let Sakari review this, but overall, I don't think we want to take
> > this direction. Objects need to be refcounted instead of freed at remove
> > time. 
> 
> I agree that refcounting could provide more robust lifetime management,
> especially for shared resources. I will think in this direction, explore 
> implementing refcounting for these objects, and share an RFC for your 
> feedback.

I agree with Laurent here when it comes to the current state of the
patches.

Tearing down things automatically, however, is what we should look into.
But I believe it will require refcounting sub-devices first, then we could
bind such resources to them. But before this, we'll need to merge the media
device refcounting series
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=media-ref>.

> 
> > This patch series doesn't necessarily cause a regression as such,
> > but it will make it more difficult to fix life time management issues in
> > V4L2.
> 
> Could you clarify how devm-managed helpers might complicate lifetime 
> management in V4L2? Understanding specific issues will help me design 
> a solution that aligns with the subsystem’s needs while keeping cleanup 
> simple.

The problem with devm_*() and UAPI is that once the device disappears, so
disappear all its resources, including those being used by whatever
programs accessing the UAPI, leading to memory safety issues. IOW devm_()
when used on memory resources in V4L2 is often simply wrong but right now
we don't have yet any better options in a lot of cases.

-- 
Kind regards,

Sakari Ailus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ