Skip to content

Commit 96d6ee7

Browse files
committed
Merge tag 'drm-fixes-2018-12-21' of git://anongit.freedesktop.org/drm/drm
Pull final drm fix from Daniel Vetter: "Very calm week, so either everything perfect or everyone on holidays already. Just one array_index_nospec patch, also for stable" * tag 'drm-fixes-2018-12-21' of git://anongit.freedesktop.org/drm/drm: drm/ioctl: Fix Spectre v1 vulnerabilities
2 parents 0b51733 + b6aac62 commit 96d6ee7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/gpu/drm/drm_ioctl.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
#include <linux/pci.h>
3939
#include <linux/export.h>
40+
#include <linux/nospec.h>
4041

4142
/**
4243
* DOC: getunique and setversion story
@@ -800,13 +801,17 @@ long drm_ioctl(struct file *filp,
800801

801802
if (is_driver_ioctl) {
802803
/* driver ioctl */
803-
if (nr - DRM_COMMAND_BASE >= dev->driver->num_ioctls)
804+
unsigned int index = nr - DRM_COMMAND_BASE;
805+
806+
if (index >= dev->driver->num_ioctls)
804807
goto err_i1;
805-
ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE];
808+
index = array_index_nospec(index, dev->driver->num_ioctls);
809+
ioctl = &dev->driver->ioctls[index];
806810
} else {
807811
/* core ioctl */
808812
if (nr >= DRM_CORE_IOCTL_COUNT)
809813
goto err_i1;
814+
nr = array_index_nospec(nr, DRM_CORE_IOCTL_COUNT);
810815
ioctl = &drm_ioctls[nr];
811816
}
812817

@@ -888,6 +893,7 @@ bool drm_ioctl_flags(unsigned int nr, unsigned int *flags)
888893

889894
if (nr >= DRM_CORE_IOCTL_COUNT)
890895
return false;
896+
nr = array_index_nospec(nr, DRM_CORE_IOCTL_COUNT);
891897

892898
*flags = drm_ioctls[nr].flags;
893899
return true;

0 commit comments

Comments
 (0)