drm/i915: Fix pid leak with banned clients
diff mbox series

Message ID 20191217161814.8358-1-tvrtko.ursulin@linux.intel.com
State New
Headers show
Series
  • drm/i915: Fix pid leak with banned clients
Related show

Commit Message

Tvrtko Ursulin Dec. 17, 2019, 4:18 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Get_pid_task() needs to be paired with a put_pid or we leak a pid
reference every time a banned client tries to create a context.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Fixes: b083a0870c79 ("drm/i915: Add per client max context ban limit")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Chris Wilson Dec. 17, 2019, 4:25 p.m. UTC | #1
Quoting Tvrtko Ursulin (2019-12-17 16:18:14)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Get_pid_task() needs to be paired with a put_pid or we leak a pid
> reference every time a banned client tries to create a context.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Fixes: b083a0870c79 ("drm/i915: Add per client max context ban limit")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_context.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 46b4d1d643f8..eace1607ceb2 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -2193,9 +2193,11 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
>  
>         ext_data.fpriv = file->driver_priv;
>         if (client_is_banned(ext_data.fpriv)) {
> +               struct pid *pid = get_task_pid(current, PIDTYPE_PID);
> +
>                 DRM_DEBUG("client %s[%d] banned from creating ctx\n",
> -                         current->comm,
> -                         pid_nr(get_task_pid(current, PIDTYPE_PID)));
> +                         current->comm, pid_nr(pid));

Or, going out on a limb here, task_pid_nr(current)).
-Chris

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 46b4d1d643f8..eace1607ceb2 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -2193,9 +2193,11 @@  int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 
 	ext_data.fpriv = file->driver_priv;
 	if (client_is_banned(ext_data.fpriv)) {
+		struct pid *pid = get_task_pid(current, PIDTYPE_PID);
+
 		DRM_DEBUG("client %s[%d] banned from creating ctx\n",
-			  current->comm,
-			  pid_nr(get_task_pid(current, PIDTYPE_PID)));
+			  current->comm, pid_nr(pid));
+		put_pid(pid);
 		return -EIO;
 	}