From a373843d072f53ad72c510826d289a0d3b9062e4 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Fri, 29 Dec 2017 16:51:10 -0800 Subject: gpu: nvgpu: add speculative load barrier (VM ioctls) Data can be speculatively loaded from memory and stay in cache even when bound check fails. This can lead to unintended information disclosure via side-channel analysis. To mitigate this problem insert a speculation barrier. bug 2039126 CVE-2017-5753 Change-Id: Idf09b8d64dbdc2b0e4b504d4d7ea0197d38157d3 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1640499 Reviewed-by: svc-mobile-coverity Reviewed-by: Richard Zhao GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/vm_area.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/nvgpu/common/mm/vm_area.c b/drivers/gpu/nvgpu/common/mm/vm_area.c index 5ed2626f..6781d915 100644 --- a/drivers/gpu/nvgpu/common/mm/vm_area.c +++ b/drivers/gpu/nvgpu/common/mm/vm_area.c @@ -22,6 +22,7 @@ #include #include +#include #include "gk20a/gk20a.h" #include "gk20a/mm_gk20a.h" @@ -111,6 +112,13 @@ int nvgpu_vm_area_alloc(struct vm_gk20a *vm, u32 pages, u32 page_size, if (pgsz_idx > gmmu_page_size_big) return -EINVAL; + /* + * pgsz_idx isn't likely to get too crazy, since it starts at 0 and + * increments but this ensures that we still have a definitely valid + * page size before proceeding. + */ + nvgpu_speculation_barrier(); + if (!vm->big_pages && pgsz_idx == gmmu_page_size_big) return -EINVAL; -- cgit v1.2.2