gpu: nvgpu: Validate buffer_offset argument

Validate the mapping_size argument in the VM mapping IOCTL before
attempting to use the argument for anything.

Bug 1954931
Bug 1965443

Change-Id: I81b22dc566c6c6f89e5e62604ce996376b33a343
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1547046
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
(cherry picked from commit e68391690c in
dev-kernel)
Reviewed-on: https://git-master.nvidia.com/r/1601531
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
This commit is contained in:
Alex Waterman
2017-08-28 10:55:26 -07:00
committed by Winnie Hsu
parent 0865b9de0c
commit 1fc57375eb

View File

@@ -2472,6 +2472,12 @@ u64 gk20a_vm_map(struct vm_gk20a *vm,
min_t(u64, bfr.size, bfr.align)); min_t(u64, bfr.size, bfr.align));
mapping_size = mapping_size ? mapping_size : bfr.size; mapping_size = mapping_size ? mapping_size : bfr.size;
if ((mapping_size > bfr.size) ||
(buffer_offset > (bfr.size - mapping_size))) {
err = -EINVAL;
goto clean_up;
}
/* Check if we should use a fixed offset for mapping this buffer */ /* Check if we should use a fixed offset for mapping this buffer */
if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) { if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) {
err = validate_fixed_buffer(vm, &bfr, err = validate_fixed_buffer(vm, &bfr,