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: <3e9e157d-e740-ee5b-b8d3-07822b2c9a9b@collabora.com>
Date:   Sun, 4 Dec 2022 23:45:26 +0300
From:   Dmitry Osipenko <dmitry.osipenko@...labora.com>
To:     Rob Clark <robdclark@...il.com>, dri-devel@...ts.freedesktop.org
Cc:     Rob Clark <robdclark@...omium.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        Daniel Vetter <daniel.vetter@...ll.ch>,
        open list <linux-kernel@...r.kernel.org>,
        stable@...r.kernel.org, Eric Anholt <eric@...olt.net>,
        Noralf Trønnes <noralf@...nnes.org>,
        syzbot+c8ae65286134dd1b800d@...kaller.appspotmail.com
Subject: Re: [PATCH v2 1/2] drm/shmem-helper: Remove errant put in error path

On 11/30/22 21:57, Rob Clark wrote:
> From: Rob Clark <robdclark@...omium.org>
> 
> drm_gem_shmem_mmap() doesn't own this reference, resulting in the GEM
> object getting prematurely freed leading to a later use-after-free.
> 
> Link: https://syzkaller.appspot.com/bug?extid=c8ae65286134dd1b800d
> Reported-by: syzbot+c8ae65286134dd1b800d@...kaller.appspotmail.com
> Fixes: 2194a63a818d ("drm: Add library for shmem backed GEM objects")
> Cc: stable@...r.kernel.org
> Signed-off-by: Rob Clark <robdclark@...omium.org>
> Reviewed-by: Daniel Vetter <daniel.vetter@...ll.ch>
> ---
>  drivers/gpu/drm/drm_gem_shmem_helper.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 35138f8a375c..3b7b71391a4c 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -622,10 +622,8 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct
>  	}
>  
>  	ret = drm_gem_shmem_get_pages(shmem);
> -	if (ret) {
> -		drm_gem_vm_close(vma);
> +	if (ret)
>  		return ret;
> -	}
>  
>  	vma->vm_flags |= VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
>  	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);

AFAICS, the dmabuf mmaping code path needs a similar fix, isn't it?

-		/* Drop the reference drm_gem_mmap_obj() acquired.*/
-		drm_gem_object_put(obj);
		vma->vm_private_data = NULL;

-		return dma_buf_mmap(obj->dma_buf, vma, 0);
+		ret = dma_buf_mmap(obj->dma_buf, vma, 0);
+
+		/* Drop the reference drm_gem_mmap_obj() acquired.*/
+		if (!ret)
+			drm_gem_object_put(obj);
+
+		return ret;


-- 
Best regards,
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ