From 141eb799078c93d0baeb59136ab55b621fd52d8b Mon Sep 17 00:00:00 2001 From: Agnes Leroy Date: Wed, 24 Jul 2024 16:43:43 +0200 Subject: [PATCH] chore(gpu): add checks in hillis&steele to avoid wrong memory access --- backends/tfhe-cuda-backend/cuda/src/integer/integer.cuh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backends/tfhe-cuda-backend/cuda/src/integer/integer.cuh b/backends/tfhe-cuda-backend/cuda/src/integer/integer.cuh index b0e8d4e7de..1d93d887bd 100644 --- a/backends/tfhe-cuda-backend/cuda/src/integer/integer.cuh +++ b/backends/tfhe-cuda-backend/cuda/src/integer/integer.cuh @@ -530,6 +530,9 @@ void host_propagate_single_carry(cudaStream_t *streams, uint32_t *gpu_indexes, gpu_indexes[0]); for (int step = 0; step < num_steps; step++) { + if (space > num_blocks - 1) + PANIC("Cuda error: step output is going out of bounds in Hillis Steele " + "propagation") auto cur_blocks = &step_output[space * big_lwe_size]; auto prev_blocks = generates_or_propagates; int cur_total_blocks = num_blocks - space; @@ -615,6 +618,9 @@ void host_propagate_single_sub_borrow(cudaStream_t *streams, gpu_indexes[0]); for (int step = 0; step < num_steps; step++) { + if (space > num_blocks - 1) + PANIC("Cuda error: step output is going out of bounds in Hillis Steele " + "propagation") auto cur_blocks = &step_output[space * big_lwe_size]; auto prev_blocks = generates_or_propagates; int cur_total_blocks = num_blocks - space;