From c240a9bc869bb66e8e1cfb605ec1d1954c465617 Mon Sep 17 00:00:00 2001 From: Jordan Crouse <jcrouse@codeaurora.org> Date: Tue, 6 May 2014 09:36:40 -0600 Subject: [PATCH] msm: kgsl: Don't set VM_IO on mmap()ed GPU memory objects VM_IO prevents mapped memory from being peeked by ptrace(). That kind of protection isn't really needed for nominal GPU buffers. A process given itself up to ptrace() already expects to be examined so there is no additional risk to let the parent examine GPU buffers too. This is done universally now, but there is no reason why we wouldn't let the process choose which buffers to keep private in the future. That said; there is more of a concern about including GPU buffers in a core dump since that is a more permanent and less secure record of the memory so add VM_DONTDUMP for all GPU buffers to protect against that. CRs-Fixed: 654751 Change-Id: Ic0dedbade91a2ec458bcb27eff3312d4ec6e4389 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> --- drivers/gpu/msm/kgsl.c | 3 +++ drivers/gpu/msm/kgsl_sharedmem.c | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c index e1ad9354c85a..efc4c69210a0 100644 --- a/drivers/gpu/msm/kgsl.c +++ b/drivers/gpu/msm/kgsl.c @@ -2912,6 +2912,9 @@ error_attach: break; } error: + /* Clear gpuaddr here so userspace doesn't get any wrong ideas */ + param->gpuaddr = 0; + kfree(entry); return result; } diff --git a/drivers/gpu/msm/kgsl_sharedmem.c b/drivers/gpu/msm/kgsl_sharedmem.c index 5d4fc0088c99..9fd10c751b6d 100755 --- a/drivers/gpu/msm/kgsl_sharedmem.c +++ b/drivers/gpu/msm/kgsl_sharedmem.c @@ -527,8 +527,7 @@ static void kgsl_cma_coherent_free(struct kgsl_memdesc *memdesc) /* Global - also used by kgsl_drm.c */ struct kgsl_memdesc_ops kgsl_page_alloc_ops = { .free = kgsl_page_alloc_free, - .vmflags = VM_IO | VM_DONTEXPAND, - //.vmflags = VM_RESERVED | VM_DONTEXPAND, + .vmflags = VM_NODUMP | VM_DONTEXPAND, .vmfault = kgsl_page_alloc_vmfault, .map_kernel = kgsl_page_alloc_map_kernel, .unmap_kernel = kgsl_page_alloc_unmap_kernel, @@ -538,8 +537,7 @@ EXPORT_SYMBOL(kgsl_page_alloc_ops); /* CMA ops - used during NOMMU mode */ static struct kgsl_memdesc_ops kgsl_cma_ops = { .free = kgsl_cma_coherent_free, - .vmflags = VM_IO | VM_PFNMAP | VM_DONTEXPAND, - //.vmflags = VM_RESERVED | VM_PFNMAP | VM_DONTEXPAND, + .vmflags = VM_NODUMP | VM_PFNMAP | VM_DONTEXPAND, .vmfault = kgsl_contiguous_vmfault, }; -- GitLab