mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-25 02:52:51 +03:00
gpu: nvgpu: fix race for channel sync read/write
CTS test dEQP-VK.api.object_management.max_concurrent.device_group crashes with invalid userspace memory access. Currently, nvgpu_submit_prepare_syncs() races with nvgpu_channel_clean_up_jobs() and this race condition is exposed when aggressive_sync_destroy_thresh is set to non-zero value. nvgpu_submit_prepare_syncs() gets ref for c->sync to submit job and releases channel sync_lock. Meanwhile, nvgpu_worker_poll_work() triggers nvgpu_channel_clean_up_jobs(), which destroys ref'd c->sync pointer. This patch protects channel's sync pointer by holding channel sync_lock during complete execution of nvgpu_submit_prepare_syncs(). Bug 2613870 Change-Id: I6f3d48aff361d1cb38c30d2ce5de276d0c55fb6f Signed-off-by: Seema Khowala <seemaj@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2176929 Reviewed-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-by: Debarshi Dutta <ddutta@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
26d955be23
commit
e22d743a20
@@ -1357,6 +1357,8 @@ void nvgpu_channel_clean_up_jobs(struct nvgpu_channel *c,
|
||||
break;
|
||||
}
|
||||
|
||||
nvgpu_mutex_acquire(&c->sync_lock);
|
||||
|
||||
WARN_ON(c->sync == NULL);
|
||||
|
||||
if (c->sync != NULL) {
|
||||
@@ -1366,16 +1368,15 @@ void nvgpu_channel_clean_up_jobs(struct nvgpu_channel *c,
|
||||
}
|
||||
|
||||
if (g->aggressive_sync_destroy_thresh != 0U) {
|
||||
nvgpu_mutex_acquire(&c->sync_lock);
|
||||
if (nvgpu_channel_sync_put_ref_and_check(c->sync)
|
||||
&& g->aggressive_sync_destroy) {
|
||||
nvgpu_channel_sync_destroy(c->sync,
|
||||
false);
|
||||
c->sync = NULL;
|
||||
}
|
||||
nvgpu_mutex_release(&c->sync_lock);
|
||||
}
|
||||
}
|
||||
nvgpu_mutex_release(&c->sync_lock);
|
||||
|
||||
if (job->num_mapped_buffers != 0U) {
|
||||
nvgpu_vm_put_buffers(vm, job->mapped_buffers,
|
||||
|
||||
Reference in New Issue
Block a user