From a55491015cf9de6295f30d4da4b7edc101550471 Mon Sep 17 00:00:00 2001 From: Martin Radev Date: Wed, 31 May 2023 12:59:28 +0300 Subject: [PATCH] gpu: nvgpu: exit early in cbc debugfs under hv This patch updates the logic for the cbc debugfs node to fail early if running under HV. The reason is that the CBC region is maintained by HV and cannot be accessed by nvgpu. This avoids a subsequent null-ptr deref for Linux + HV. Bug 4131079 Change-Id: I1ac1919efc1c05fb679f19a189184ca00908856f Signed-off-by: Martin Radev Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2913160 Reviewed-by: Sagar Kamble Reviewed-by: Ankur Kishore Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/debug_gr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/nvgpu/os/linux/debug_gr.c b/drivers/gpu/nvgpu/os/linux/debug_gr.c index 1ebb865ff..13f5c6e99 100644 --- a/drivers/gpu/nvgpu/os/linux/debug_gr.c +++ b/drivers/gpu/nvgpu/os/linux/debug_gr.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "common/gr/ctx_priv.h" #include "common/gr/gr_priv.h" @@ -84,6 +85,9 @@ static int cbc_status_debug_open(struct inode *inode, struct file *file) if (!capable(CAP_SYS_ADMIN)) { return -EPERM; } + if (nvgpu_is_hypervisor_mode(g)) { + return -EPERM; + } g = nvgpu_get(g); if (!g) { return -ENODEV;