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:   Wed, 30 Nov 2022 15:03:10 +0100
From:   Daniel Vetter <daniel@...ll.ch>
To:     Rob Clark <robdclark@...il.com>
Cc:     dri-devel@...ts.freedesktop.org, Daniel Vetter <daniel@...ll.ch>,
        Rob Clark <robdclark@...omium.org>, stable@...r.kernel.org,
        Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Maxime Ripard <mripard@...nel.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        David Airlie <airlied@...il.com>,
        Eric Anholt <eric@...olt.net>,
        Noralf Trønnes <noralf@...nnes.org>,
        Rob Herring <robh@...nel.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] drm/shmem-helper: Avoid vm_open error paths

On Tue, Nov 29, 2022 at 12:02:42PM -0800, Rob Clark wrote:
> From: Rob Clark <robdclark@...omium.org>
>
> vm_open() is not allowed to fail.  Fortunately we are guaranteed that
> the pages are already pinned, and only need to increment the refcnt.  So
> just increment it directly.

Please mention hare that the only issue is the mutex_lock_interruptible,
and the only way we've found to hit this is if you send a signal to the
original process in a fork() at _just_ the right time.

With that: Reviewed-by: Daniel Vetter <daniel.vetter@...ll.ch>

>
> Fixes: 2194a63a818d ("drm: Add library for shmem backed GEM objects")
> Cc: stable@...r.kernel.org
> Signed-off-by: Rob Clark <robdclark@...omium.org>
> ---
>  drivers/gpu/drm/drm_gem_shmem_helper.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 110a9eac2af8..9885ba64127f 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -571,12 +571,20 @@ static void drm_gem_shmem_vm_open(struct vm_area_struct *vma)
>  {
>       struct drm_gem_object *obj = vma->vm_private_data;
>       struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
> -     int ret;
>
>       WARN_ON(shmem->base.import_attach);
>
> -     ret = drm_gem_shmem_get_pages(shmem);
> -     WARN_ON_ONCE(ret != 0);
> +     mutex_lock(&shmem->pages_lock);
> +
> +     /*
> +      * We should have already pinned the pages, vm_open() just grabs
> +      * an additional reference for the new mm the vma is getting
> +      * copied into.
> +      */
> +     WARN_ON_ONCE(!shmem->pages_use_count);
> +
> +     shmem->pages_use_count++;
> +     mutex_unlock(&shmem->pages_lock);
>
>       drm_gem_vm_open(vma);
>  }
> --
> 2.38.1
>

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ