From 363b183756728908448497b440dde96f96fce387 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Thu, 9 Jul 2020 16:11:26 +0530 Subject: gpu: nvgpu: advertise RESCHEDULE_RUNLIST capability only for realtime processes Below change added capability check in the ioctl. nvgpu is advertising the support for RESCHEDULE_RUNLIST for all processes even though it fails the ioctl for non-realtime processes. Clear the ioctl flag for RESCHEDULE_RUNLIST for non-realtime processes. commit 838ba0a14d61f ("gpu: nvgpu: check capability for reschedule runlist submit flag") Author: David Li Date: Tue Sep 12 18:37:00 2017 -0700 NVGPU_SUBMIT_GPFIFO_FLAGS_RESCHEDULE_RUNLIST is only used by realtime priority EGL context, which checks for CAP_SYS_NICE during context creation in userspace, so it wasn't secure against unprivileged program spoofing submit ioctl with this flag to stall GPU progress of others. This flag does increase duration of submit by approx 16us, mostly due to register accesses and PMU FIFO mutex. Bug 2823941 Change-Id: Iecee3989e5af035264b1ed5c1aa9a8576dd90883 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2372957 (cherry picked from commit 864213ae55b009b0a026ac380b26276332f79177) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2392714 Reviewed-by: automaticguardword Reviewed-by: Bibek Basu Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index 954b08b5..ee141ff8 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c @@ -239,6 +239,10 @@ static u64 nvgpu_ctrl_ioctl_gpu_characteristics_flags(struct gk20a *g) ioctl_flags |= flags_mapping[i].ioctl_flag; } + if (!capable(CAP_SYS_NICE)) { + ioctl_flags &= ~NVGPU_GPU_FLAGS_SUPPORT_RESCHEDULE_RUNLIST; + } + return ioctl_flags; } -- cgit v1.2.2