All of lore.kernel.org
 help / color / mirror / Atom feed
* Kernel patch: validate nouveau_channel_get id argument
@ 2010-12-24 17:12 Michel Hermier
       [not found] ` <AANLkTikRCm19--tRgjAJqcLgb1f_hWcWJpRvgAqGKfQw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Michel Hermier @ 2010-12-24 17:12 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

[-- Attachment #1: Type: text/plain, Size: 351 bytes --]

Hi,
While hacking libdrm I triggered a kernel oups due to a non checked
argument from user land.
In nouveau_ioctl_notifier_alloc, nouveau_channel_get is invoked, but
it doesn't validate the na->channel input argument. The attached patch
validates the channel index, and change it's type to uint32_t since it
is an index after all.

Cheers,
    Michel

[-- Attachment #2: 0001-Fix-channel-nouveau_channel_get-index-type-and-check.patch --]
[-- Type: application/octet-stream, Size: 2042 bytes --]

From dc00e5ccce3f10e51ae143d6dda6aa8febab271d Mon Sep 17 00:00:00 2001
From: Michel Hermier <hermier@frugalware.org>
Date: Fri, 24 Dec 2010 14:49:13 +0100
Subject: [PATCH] Fix channel nouveau_channel_get index type and check it's value.

---
 drivers/gpu/drm/nouveau/nouveau_channel.c |    5 ++++-
 drivers/gpu/drm/nouveau/nouveau_drv.h     |    2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index e37977d..bc07a61 100644
--- a/drivers/gpu/drm/nouveau/nouveau_channel.c
+++ b/drivers/gpu/drm/nouveau/nouveau_channel.c
@@ -247,12 +247,15 @@ nouveau_channel_get_unlocked(struct nouveau_channel *ref)
 }
 
 struct nouveau_channel *
-nouveau_channel_get(struct drm_device *dev, struct drm_file *file_priv, int id)
+nouveau_channel_get(struct drm_device *dev, struct drm_file *file_priv, uint32_t id)
 {
 	struct drm_nouveau_private *dev_priv = dev->dev_private;
 	struct nouveau_channel *chan;
 	unsigned long flags;
 
+	if (unlikely(id >= NOUVEAU_MAX_CHANNEL_NR))
+		return ERR_PTR(-EINVAL);
+
 	spin_lock_irqsave(&dev_priv->channels.lock, flags);
 	chan = nouveau_channel_get_unlocked(dev_priv->channels.ptr[id]);
 	spin_unlock_irqrestore(&dev_priv->channels.lock, flags);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index e815756..ec3eed2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -870,7 +870,7 @@ extern int  nouveau_channel_alloc(struct drm_device *dev,
 extern struct nouveau_channel *
 nouveau_channel_get_unlocked(struct nouveau_channel *);
 extern struct nouveau_channel *
-nouveau_channel_get(struct drm_device *, struct drm_file *, int id);
+nouveau_channel_get(struct drm_device *, struct drm_file *, uint32_t id);
 extern void nouveau_channel_put_unlocked(struct nouveau_channel **);
 extern void nouveau_channel_put(struct nouveau_channel **);
 extern void nouveau_channel_ref(struct nouveau_channel *chan,
-- 
1.7.3.4


[-- Attachment #3: Type: text/plain, Size: 181 bytes --]

_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-12-26 11:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-24 17:12 Kernel patch: validate nouveau_channel_get id argument Michel Hermier
     [not found] ` <AANLkTikRCm19--tRgjAJqcLgb1f_hWcWJpRvgAqGKfQw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-25 13:46   ` Francisco Jerez
     [not found]     ` <87r5d6yngq.fsf-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org>
2010-12-25 15:47       ` Michel Hermier
     [not found]         ` <AANLkTi=cy3Mm4U3zk6-6WXBCPJXqyh4Q8SV_UOBQFNbU-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-25 16:20           ` Michel Hermier
     [not found]             ` <AANLkTikQP2DtprBkFr0z1q5vdb=FwDLc5R-Zeuv7ypz1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-25 18:34               ` Francisco Jerez
     [not found]                 ` <87sjxlwvjr.fsf-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org>
2010-12-26 10:37                   ` Michel Hermier
     [not found]                     ` <AANLkTin54dTRksN8JfThwS7-zi3Na+j=HdEfyxm=tav1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-26 11:00                       ` Francisco Jerez
     [not found]                         ` <87oc88x0gx.fsf-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org>
2010-12-26 11:07                           ` Michel Hermier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.