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] [day] [month] [year] [list]
Message-ID: <20241125160758.2e0fa766@collabora.com>
Date: Mon, 25 Nov 2024 16:07:58 +0100
From: Boris Brezillon <boris.brezillon@...labora.com>
To: Adrián Larumbe <adrian.larumbe@...labora.com>
Cc: Steven Price <steven.price@....com>, Liviu Dudau <liviu.dudau@....com>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard
 <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, David Airlie
 <airlied@...il.com>, Simona Vetter <simona@...ll.ch>, kernel@...labora.com,
 dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] drm/panthor: register size of internal objects
 through fdinfo

Hi Adrian,

On Fri, 15 Nov 2024 19:14:18 +0000
Adrián Larumbe <adrian.larumbe@...labora.com> wrote:

> @@ -71,9 +112,9 @@ void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)
>   * Return: A valid pointer in case of success, an ERR_PTR() otherwise.
>   */
>  struct panthor_kernel_bo *
> -panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,
> -			 size_t size, u32 bo_flags, u32 vm_map_flags,
> -			 u64 gpu_va)
> +panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_file *pfile,
> +			 struct panthor_vm *vm, size_t size, u32 bo_flags,
> +			 u32 vm_map_flags, u64 gpu_va)
>  {
>  	struct drm_gem_shmem_object *obj;
>  	struct panthor_kernel_bo *kbo;
> @@ -116,6 +157,16 @@ panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,
>  	bo->exclusive_vm_root_gem = panthor_vm_root_gem(vm);
>  	drm_gem_object_get(bo->exclusive_vm_root_gem);
>  	bo->base.base.resv = bo->exclusive_vm_root_gem->resv;
> +
> +	INIT_LIST_HEAD(&kbo->private_obj);
> +
> +	/* Only FW regions are not bound to an open file */
> +	if (pfile) {
> +		mutex_lock(&ptdev->private_obj_list_lock);
> +		list_add(&kbo->private_obj, &pfile->private_file_list);
> +		mutex_unlock(&ptdev->private_obj_list_lock);

I hate the fact we have to take a device lock to insert/remove elements
in the private_file list. I'd rather opt for an idr map (like we have
for public GEM handles), with the pfile owning a ref to the internal
GEMs.

When the kbo needs to be added to the pfile kbo list, you pass a
non-NULL pfile and let panthor_kernel_bo_create() add the entry to the
IDR. In the destroy path, you remove the entry, and reset the
kbo->handle value, to make sure panthor_kernel_bo_destroy() is not
called a second time with a non-NULL pfile. This way your lock can be
moved to panthor_file, and you don't have to worry about UAFs on the
pfile object.

> +	}
> +
>  	return kbo;
>  
>  err_free_va:

Regards,

Boris

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ