From 02c35ec0a28b4fffcfc09ca444f7dc0c0912216d Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 21 Dec 2004 17:13:22 +0000 Subject: [PATCH] via DRM: Tightened the security for some functions of the DRM_IOCTL_VIA_DMA_INIT IOCTL. Bumped patchlevel and driver date. XFree86 bug: 2119 --- shared-core/via_dma.c | 13 ++++++++++--- shared-core/via_drv.h | 4 ++-- shared/via.h | 4 ++-- shared/via_dma.c | 13 ++++++++++--- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/shared-core/via_dma.c b/shared-core/via_dma.c index ce471a25..cfeb53b8 100644 --- a/shared-core/via_dma.c +++ b/shared-core/via_dma.c @@ -191,13 +191,20 @@ int via_dma_init(DRM_IOCTL_ARGS) switch (init.func) { case VIA_INIT_DMA: - retcode = via_initialize(dev, dev_priv, &init); + if (!capable(CAP_SYS_ADMIN)) + retcode = DRM_ERR(EPERM); + else + retcode = via_initialize(dev, dev_priv, &init); break; case VIA_CLEANUP_DMA: - retcode = via_dma_cleanup(dev); + if (!capable(CAP_SYS_ADMIN)) + retcode = DRM_ERR(EPERM); + else + retcode = via_dma_cleanup(dev); break; case VIA_DMA_INITIALIZED: - retcode = (dev_priv->ring.virtual_start != NULL) ? 0: DRM_ERR( EFAULT ); + retcode = (dev_priv->ring.virtual_start != NULL) ? + 0: DRM_ERR( EFAULT ); break; default: retcode = DRM_ERR(EINVAL); diff --git a/shared-core/via_drv.h b/shared-core/via_drv.h index 01d36e4b..b2422fcf 100644 --- a/shared-core/via_drv.h +++ b/shared-core/via_drv.h @@ -28,11 +28,11 @@ #define DRIVER_NAME "via" #define DRIVER_DESC "VIA Unichrome" -#define DRIVER_DATE "20041220" +#define DRIVER_DATE "20041221" #define DRIVER_MAJOR 2 #define DRIVER_MINOR 3 -#define DRIVER_PATCHLEVEL 2 +#define DRIVER_PATCHLEVEL 3 typedef struct drm_via_ring_buffer { drm_map_t map; diff --git a/shared/via.h b/shared/via.h index 960f5e2d..2811d786 100644 --- a/shared/via.h +++ b/shared/via.h @@ -30,11 +30,11 @@ #define DRIVER_NAME "via" #define DRIVER_DESC "VIA Unichrome" -#define DRIVER_DATE "20041220" +#define DRIVER_DATE "20041221" #define DRIVER_MAJOR 2 #define DRIVER_MINOR 3 -#define DRIVER_PATCHLEVEL 2 +#define DRIVER_PATCHLEVEL 3 #define DRIVER_IOCTLS \ [DRM_IOCTL_NR(DRM_IOCTL_VIA_ALLOCMEM)] = { via_mem_alloc, 1, 0 }, \ diff --git a/shared/via_dma.c b/shared/via_dma.c index a5c4b0a3..000d4b0c 100644 --- a/shared/via_dma.c +++ b/shared/via_dma.c @@ -192,13 +192,20 @@ int via_dma_init(DRM_IOCTL_ARGS) switch (init.func) { case VIA_INIT_DMA: - retcode = via_initialize(dev, dev_priv, &init); + if (!capable(CAP_SYS_ADMIN)) + retcode = DRM_ERR(EPERM); + else + retcode = via_initialize(dev, dev_priv, &init); break; case VIA_CLEANUP_DMA: - retcode = via_dma_cleanup(dev); + if (!capable(CAP_SYS_ADMIN)) + retcode = DRM_ERR(EPERM); + else + retcode = via_dma_cleanup(dev); break; case VIA_DMA_INITIALIZED: - retcode = (dev_priv->ring.virtual_start != NULL) ? 0: DRM_ERR( EFAULT ); + retcode = (dev_priv->ring.virtual_start != NULL) ? + 0: DRM_ERR( EFAULT ); break; default: retcode = DRM_ERR(EINVAL);