소스 검색

radeon/kms: fix dma relocation checking

We were checking the index against the size of the relocation buffer
instead of against the last index. This fix kernel segfault when
userspace submit ill formated command stream/relocation buffer pair.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Jerome Glisse 12 년 전
부모
커밋
9305ede6af
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      drivers/gpu/drm/radeon/r600_cs.c

+ 3 - 3
drivers/gpu/drm/radeon/r600_cs.c

@@ -2563,16 +2563,16 @@ int r600_dma_cs_next_reloc(struct radeon_cs_parser *p,
 	struct radeon_cs_chunk *relocs_chunk;
 	struct radeon_cs_chunk *relocs_chunk;
 	unsigned idx;
 	unsigned idx;
 
 
+	*cs_reloc = NULL;
 	if (p->chunk_relocs_idx == -1) {
 	if (p->chunk_relocs_idx == -1) {
 		DRM_ERROR("No relocation chunk !\n");
 		DRM_ERROR("No relocation chunk !\n");
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
-	*cs_reloc = NULL;
 	relocs_chunk = &p->chunks[p->chunk_relocs_idx];
 	relocs_chunk = &p->chunks[p->chunk_relocs_idx];
 	idx = p->dma_reloc_idx;
 	idx = p->dma_reloc_idx;
-	if (idx >= relocs_chunk->length_dw) {
+	if (idx >= p->nrelocs) {
 		DRM_ERROR("Relocs at %d after relocations chunk end %d !\n",
 		DRM_ERROR("Relocs at %d after relocations chunk end %d !\n",
-			  idx, relocs_chunk->length_dw);
+			  idx, p->nrelocs);
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 	*cs_reloc = p->relocs_ptr[idx];
 	*cs_reloc = p->relocs_ptr[idx];