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: <20180529070200.GW3438@phenom.ffwll.local>
Date:   Tue, 29 May 2018 09:02:00 +0200
From:   Daniel Vetter <daniel@...ll.ch>
To:     Oleksandr Andrushchenko <andr2000@...il.com>
Cc:     linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
        airlied@...ux.ie, daniel.vetter@...el.com, seanpaul@...omium.org,
        gustavo@...ovan.org,
        Oleksandr Andrushchenko <oleksandr_andrushchenko@...m.com>
Subject: Re: [PATCH] drm: Fix possible race conditions while unplugging DRM
 device

On Tue, May 22, 2018 at 05:13:04PM +0300, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@...m.com>
> 
> When unplugging a hotpluggable DRM device we first unregister it
> with drm_dev_unregister and then set drm_device.unplugged flag which
> is used to mark device critical sections with drm_dev_enter()/
> drm_dev_exit() preventing access to device resources that are not
> available after the device is gone.
> But drm_dev_unregister may lead to hotplug uevent(s) fired to
> user-space on card and/or connector removal, thus making it possible
> for user-space to try accessing a disconnected device.
> 
> Fix this by first making sure device is properly marked as
> disconnected and only then unregister it.
> 
> Fixes: bee330f3d672 ("drm: Use srcu to protect drm_device.unplugged")
> 
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@...m.com>
> Reported-by: Andrii Chepurnyi <andrii_chepurnyi@...m.com>
> Cc: "Noralf Trønnes" <noralf@...nnes.org>

Nice catch.

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

I think you need to push this to drm-misc-next-fixes to make sure it's on
the 4.17 train.
-Daniel

> ---
>  drivers/gpu/drm/drm_drv.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index b553a6f2ff0e..7af748ed1c58 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -369,13 +369,6 @@ EXPORT_SYMBOL(drm_dev_exit);
>   */
>  void drm_dev_unplug(struct drm_device *dev)
>  {
> -	drm_dev_unregister(dev);
> -
> -	mutex_lock(&drm_global_mutex);
> -	if (dev->open_count == 0)
> -		drm_dev_put(dev);
> -	mutex_unlock(&drm_global_mutex);
> -
>  	/*
>  	 * After synchronizing any critical read section is guaranteed to see
>  	 * the new value of ->unplugged, and any critical section which might
> @@ -384,6 +377,13 @@ void drm_dev_unplug(struct drm_device *dev)
>  	 */
>  	dev->unplugged = true;
>  	synchronize_srcu(&drm_unplug_srcu);
> +
> +	drm_dev_unregister(dev);
> +
> +	mutex_lock(&drm_global_mutex);
> +	if (dev->open_count == 0)
> +		drm_dev_put(dev);
> +	mutex_unlock(&drm_global_mutex);
>  }
>  EXPORT_SYMBOL(drm_dev_unplug);
>  
> -- 
> 2.17.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@...ts.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ