Skip to content

Commit 5805977

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/drm-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/drm-2.6: drm: Copy back ioctl data to userspace regardless of return code. drm: Round size of SHM maps to PAGE_SIZE
2 parents a9523f4 + 9b6fe31 commit 5805977

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

drivers/gpu/drm/drm_bufs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
170170
}
171171
DRM_DEBUG("offset = 0x%08llx, size = 0x%08lx, type = %d\n",
172172
(unsigned long long)map->offset, map->size, map->type);
173+
174+
/* page-align _DRM_SHM maps. They are allocated here so there is no security
175+
* hole created by that and it works around various broken drivers that use
176+
* a non-aligned quantity to map the SAREA. --BenH
177+
*/
178+
if (map->type == _DRM_SHM)
179+
map->size = PAGE_ALIGN(map->size);
180+
173181
if ((map->offset & (~(resource_size_t)PAGE_MASK)) || (map->size & (~PAGE_MASK))) {
174182
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
175183
return -EINVAL;

drivers/gpu/drm/drm_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ int drm_ioctl(struct inode *inode, struct file *filp,
481481
}
482482
retcode = func(dev, kdata, file_priv);
483483

484-
if ((retcode == 0) && (cmd & IOC_OUT)) {
484+
if (cmd & IOC_OUT) {
485485
if (copy_to_user((void __user *)arg, kdata,
486486
_IOC_SIZE(cmd)) != 0)
487487
retcode = -EFAULT;

0 commit comments

Comments
 (0)