]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/nouveau: Validate channel indices passed from userspace.
authorMichel Hermier <hermier@frugalware.org>
Sat, 25 Dec 2010 15:58:56 +0000 (16:58 +0100)
committerBen Skeggs <bskeggs@redhat.com>
Mon, 27 Dec 2010 00:41:01 +0000 (10:41 +1000)
When hacking the libdrm for improvements, I triggered a kernel crash
related to the fact that the NOUVEAU_NOTIFIEROBJ_ALLOC ioctl calls
nouveau_channel_get with an unchecked channel index.
The patch ensures that the channel index is an unsigned and validates
its value in nouveau_channel_get.

Signed-off-by: Michel Hermier <hermier@frugalware.org>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_channel.c

index e37977d0246363aa7c4295360863f39f449f7dce..4d2f19420922d549799db2af44cb68f0bb5446a2 100644 (file)
@@ -253,6 +253,9 @@ nouveau_channel_get(struct drm_device *dev, struct drm_file *file_priv, int id)
        struct nouveau_channel *chan;
        unsigned long flags;
 
+       if (unlikely(id < 0 || 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);