aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@amacapital.net>2013-05-13 19:58:48 -0400
committerDave Airlie <airlied@redhat.com>2013-05-30 23:37:39 -0400
commit0dd99f1bfc8a3661f095c00f9f86f5bafbd4fdff (patch)
tree20f13d7a2e54acff0871bc92d111665e80dd0668
parent03dae7c567d24c49e826a033df45802ac9d1d6c8 (diff)
drm: Don't leak phys_wc "handles" to userspace
I didn't fix this in the earlier patch -- it would have broken the build due to the now-deleted garbage in drm_os_linux.h. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Andy Lutomirski <luto@amacapital.net> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_bufs.c9
-rw-r--r--drivers/gpu/drm/drm_ioctl.c15
2 files changed, 23 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 0190fce20078..5a4dbb410b71 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -414,6 +414,15 @@ int drm_addmap_ioctl(struct drm_device *dev, void *data,
414 414
415 /* avoid a warning on 64-bit, this casting isn't very nice, but the API is set so too late */ 415 /* avoid a warning on 64-bit, this casting isn't very nice, but the API is set so too late */
416 map->handle = (void *)(unsigned long)maplist->user_token; 416 map->handle = (void *)(unsigned long)maplist->user_token;
417
418 /*
419 * It appears that there are no users of this value whatsoever --
420 * drmAddMap just discards it. Let's not encourage its use.
421 * (Keeping drm_addmap_core's returned mtrr value would be wrong --
422 * it's not a real mtrr index anymore.)
423 */
424 map->mtrr = -1;
425
417 return 0; 426 return 0;
418} 427}
419 428
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index e77bd8b57df2..ffd7a7ba70d4 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -38,6 +38,9 @@
38 38
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/export.h> 40#include <linux/export.h>
41#ifdef CONFIG_X86
42#include <asm/mtrr.h>
43#endif
41 44
42/** 45/**
43 * Get the bus id. 46 * Get the bus id.
@@ -181,7 +184,17 @@ int drm_getmap(struct drm_device *dev, void *data,
181 map->type = r_list->map->type; 184 map->type = r_list->map->type;
182 map->flags = r_list->map->flags; 185 map->flags = r_list->map->flags;
183 map->handle = (void *)(unsigned long) r_list->user_token; 186 map->handle = (void *)(unsigned long) r_list->user_token;
184 map->mtrr = r_list->map->mtrr; 187
188#ifdef CONFIG_X86
189 /*
190 * There appears to be exactly one user of the mtrr index: dritest.
191 * It's easy enough to keep it working on non-PAT systems.
192 */
193 map->mtrr = phys_wc_to_mtrr_index(r_list->map->mtrr);
194#else
195 map->mtrr = -1;
196#endif
197
185 mutex_unlock(&dev->struct_mutex); 198 mutex_unlock(&dev->struct_mutex);
186 199
187 return 0; 200 return 0;