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]
Date:   Tue, 22 Feb 2022 16:28:24 +0000
From:   Tvrtko Ursulin <tvrtko.ursulin@...ux.intel.com>
To:     Yongzhi Liu <lyz_cs@....edu.cn>, jani.nikula@...ux.intel.com,
        joonas.lahtinen@...ux.intel.com, rodrigo.vivi@...el.com,
        airlied@...ux.ie, daniel@...ll.ch,
        thomas.hellstrom@...ux.intel.com,
        maarten.lankhorst@...ux.intel.com, matthew.auld@...el.com,
        matthew.d.roper@...el.com, tzimmermann@...e.de,
        michal.winiarski@...el.com
Cc:     intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/i915: Check input parameter for NULL


Hi,

On 22/02/2022 14:46, Yongzhi Liu wrote:
> [why]
> i915_gem_object_put_pages_phys() frees pages and standard
> pattern is to allow caller to not care if it's
> NULL or not. This will reduce burden on
> the callers to perform this check.

I don't think we want this in general, and definitely not just for phys 
objects and leaving others not handle NULL.

See comment at the call site for these vfuncs:

	/*
	 * XXX Temporary hijinx to avoid updating all backends to handle
	 * NULL pages. In the future, when we have more asynchronous
	 * get_pages backends we should be better able to handle the
	 * cancellation of the async task in a more uniform manner.
	 */
	if (!IS_ERR_OR_NULL(pages))
		obj->ops->put_pages(obj, pages);

Maarten owns this area these days so he can comment as well.

Regards,

Tvrtko

> [how]
> Fix it by adding Null check.
> 
> Signed-off-by: Yongzhi Liu <lyz_cs@....edu.cn>
> ---
>   drivers/gpu/drm/i915/gem/i915_gem_phys.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_phys.c b/drivers/gpu/drm/i915/gem/i915_gem_phys.c
> index ca6faff..09c3dcb 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_phys.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_phys.c
> @@ -95,8 +95,13 @@ void
>   i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj,
>   			       struct sg_table *pages)
>   {
> -	dma_addr_t dma = sg_dma_address(pages->sgl);
> -	void *vaddr = sg_page(pages->sgl);
> +	dma_addr_t dma;
> +	void *vaddr;
> +
> +	if (!pages)
> +		return;
> +	dma = sg_dma_address(pages->sgl);
> +	vaddr = sg_page(pages->sgl);
>   
>   	__i915_gem_object_release_shmem(obj, pages, false);
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ