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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <oypijda53wra8v.fsf%l.stelmach@samsung.com>
Date: Mon, 18 Aug 2025 16:10:40 +0200
From: Lukasz Stelmach <l.stelmach@...sung.com>
To: Jacopo Mondi <jacopo.mondi@...asonboard.com>
Cc: Laurent Pinchart <laurent.pinchart@...asonboard.com>,
	linux-media@...r.kernel.org,  linux-kernel@...r.kernel.org,
	linux-staging@...ts.linux.dev,  linux-doc@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, linux-mediatek@...ts.infradead.org, 
	linux-tegra@...r.kernel.org, imx@...ts.linux.dev, 
	linux-renesas-soc@...r.kernel.org, linux-arm-msm@...r.kernel.org, 
	linux-samsung-soc@...r.kernel.org, linux-sunxi@...ts.linux.dev, 
	linux-usb@...r.kernel.org, linux-amlogic@...ts.infradead.org, 
	linux-rockchip@...ts.infradead.org,
	linux-stm32@...md-mailman.stormreply.com, mjpeg-users@...ts.sourceforge.net
Subject: Re: [PATCH 11/65] media: Replace file->private_data access with
 custom functions

It was <2025-08-02 sob 11:22>, when Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
>
> Accessing file->private_data manually to retrieve the v4l2_fh pointer is
> error-prone, as the field is a void * and will happily cast implicitly
> to any pointer type.
>
> Replace all remaining locations that read the v4l2_fh pointer directly
> from file->private_data and cast it to driver-specific file handle
> structures with driver-specific functions that use file_to_v4l2_fh() and
> perform the same cast.
>
> No functional change is intended, this only paves the way to remove
> direct accesses to file->private_data and make V4L2 drivers safer.
> Other accesses to the field will be addressed separately.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@...asonboard.com>
> ---

[...]

> diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.c
> index ffed16a34493be2edbdaee13619467417487c1e7..44fcedbbc90a9863827aacbcd5f56d850cb552ea 100644
> --- a/drivers/media/platform/samsung/s5p-g2d/g2d.c
> +++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c
> @@ -25,7 +25,10 @@
>  #include "g2d.h"
>  #include "g2d-regs.h"
>  
> -#define fh2ctx(__fh) container_of(__fh, struct g2d_ctx, fh)
> +static inline struct g2d_ctx *file2ctx(struct file *filp)
> +{
> +	return container_of(file_to_v4l2_fh(filp), struct g2d_ctx, fh);
> +}
>  
>  static struct g2d_fmt formats[] = {
>  	{
> @@ -272,7 +275,7 @@ static int g2d_open(struct file *file)
>  static int g2d_release(struct file *file)
>  {
>  	struct g2d_dev *dev = video_drvdata(file);
> -	struct g2d_ctx *ctx = fh2ctx(file->private_data);
> +	struct g2d_ctx *ctx = file2ctx(file);
>  
>  	mutex_lock(&dev->mutex);
>  	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);


Acked-by: Lukasz Stelmach <l.stelmach@...sung.com>


[...]


-- 
Ɓukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics

Download attachment "signature.asc" of type "application/pgp-signature" (488 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ