summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/panthor/panthor_drv.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2024-09-06 11:25:38 +1000
committerDave Airlie <airlied@redhat.com>2024-09-06 11:25:46 +1000
commitca10367a5abe5f04df1374b227a10439ef686b90 (patch)
treed5be738851922d962f9146ec39c706aabd41bece /drivers/gpu/drm/panthor/panthor_drv.c
parent4de4a0f160cf8ccf29a9a70f00403e6948e7e108 (diff)
parent5a498d4d06d6d9bad76d8a50a7f8fe01670ad46f (diff)
downloadlinux-ca10367a5abe5f04df1374b227a10439ef686b90.tar.gz
linux-ca10367a5abe5f04df1374b227a10439ef686b90.tar.bz2
linux-ca10367a5abe5f04df1374b227a10439ef686b90.zip
Merge tag 'drm-misc-fixes-2024-09-05' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes
A zpos normalization fix for komeda, a register bitmask fix for nouveau, a memory leak fix for imagination, three fixes for the recent bridge HDMI work, a potential DoS fix and a cache coherency for panthor, a change of panel compatible and a deferred-io fix when used with non-highmem memory. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maxime Ripard <mripard@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240905-original-radical-guan-e7a2ae@houat
Diffstat (limited to 'drivers/gpu/drm/panthor/panthor_drv.c')
-rw-r--r--drivers/gpu/drm/panthor/panthor_drv.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
index b5e7b919f241..34182f67136c 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -10,6 +10,7 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <drm/drm_auth.h>
#include <drm/drm_debugfs.h>
#include <drm/drm_drv.h>
#include <drm/drm_exec.h>
@@ -996,6 +997,24 @@ static int panthor_ioctl_group_destroy(struct drm_device *ddev, void *data,
return panthor_group_destroy(pfile, args->group_handle);
}
+static int group_priority_permit(struct drm_file *file,
+ u8 priority)
+{
+ /* Ensure that priority is valid */
+ if (priority > PANTHOR_GROUP_PRIORITY_HIGH)
+ return -EINVAL;
+
+ /* Medium priority and below are always allowed */
+ if (priority <= PANTHOR_GROUP_PRIORITY_MEDIUM)
+ return 0;
+
+ /* Higher priorities require CAP_SYS_NICE or DRM_MASTER */
+ if (capable(CAP_SYS_NICE) || drm_is_current_master(file))
+ return 0;
+
+ return -EACCES;
+}
+
static int panthor_ioctl_group_create(struct drm_device *ddev, void *data,
struct drm_file *file)
{
@@ -1011,6 +1030,10 @@ static int panthor_ioctl_group_create(struct drm_device *ddev, void *data,
if (ret)
return ret;
+ ret = group_priority_permit(file, args->priority);
+ if (ret)
+ return ret;
+
ret = panthor_group_create(pfile, args, queue_args);
if (ret >= 0) {
args->group_handle = ret;