]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm: prevent a harmless integer overflow in drm_legacy_sg_alloc()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 28 Feb 2020 09:23:21 +0000 (12:23 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 28 Feb 2020 23:16:12 +0000 (00:16 +0100)
There is an integer overflow when we round up to PAGE_SIZE, but it's
harmless because we never re-use "request->size" for anything meaningful.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20200228092321.axulddmkxrujkmas@kili.mountain
drivers/gpu/drm/drm_scatter.c

index d5c386154246e3da2ee3911862b1de4d5ee95195..ca520028b2cb1db39d10d6de223524299737d064 100644 (file)
@@ -99,6 +99,9 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
        if (!drm_core_check_feature(dev, DRIVER_SG))
                return -EOPNOTSUPP;
 
+       if (request->size > SIZE_MAX - PAGE_SIZE)
+               return -EINVAL;
+
        if (dev->sg)
                return -EINVAL;