Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Lutomirski and committed by
Dave Airlie
0dd99f1b 03dae7c5

+23 -1
+9
drivers/gpu/drm/drm_bufs.c
··· 414 414 415 415 /* avoid a warning on 64-bit, this casting isn't very nice, but the API is set so too late */ 416 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 426 return 0; 418 427 } 419 428
+14 -1
drivers/gpu/drm/drm_ioctl.c
··· 38 38 39 39 #include <linux/pci.h> 40 40 #include <linux/export.h> 41 + #ifdef CONFIG_X86 42 + #include <asm/mtrr.h> 43 + #endif 41 44 42 45 /** 43 46 * Get the bus id. ··· 184 181 map->type = r_list->map->type; 185 182 map->flags = r_list->map->flags; 186 183 map->handle = (void *)(unsigned long) r_list->user_token; 187 - map->mtrr = r_list->map->mtrr; 184 + 185 + #ifdef CONFIG_X86 186 + /* 187 + * There appears to be exactly one user of the mtrr index: dritest. 188 + * It's easy enough to keep it working on non-PAT systems. 189 + */ 190 + map->mtrr = phys_wc_to_mtrr_index(r_list->map->mtrr); 191 + #else 192 + map->mtrr = -1; 193 + #endif 194 + 188 195 mutex_unlock(&dev->struct_mutex); 189 196 190 197 return 0;