Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2147 from ekuznetsov139/master
Browse files Browse the repository at this point in the history
Avoiding buffer overflow in SHA3
  • Loading branch information
jean-m-cyr authored Feb 10, 2021
2 parents 47ae149 + 9cb460b commit ce52c74
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libethash-cuda/ethash_cuda_miner_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ __global__ void ethash_calculate_dag_item(uint32_t start)
uint32_t const node_index = start + blockIdx.x * blockDim.x + threadIdx.x;
if (((node_index >> 1) & (~1)) >= d_dag_size)
return;

hash128_t dag_node;
union {
hash128_t dag_node;
uint2 dag_node_mem[25];
};
copy(dag_node.uint4s, d_light[node_index % d_light_size].uint4s, 4);
dag_node.words[0] ^= node_index;
SHA3_512(dag_node.uint2s);
SHA3_512(dag_node_mem);

const int thread_id = threadIdx.x & 3;

Expand All @@ -78,7 +80,7 @@ __global__ void ethash_calculate_dag_item(uint32_t start)
}
}
}
SHA3_512(dag_node.uint2s);
SHA3_512(dag_node_mem);
hash64_t* dag_nodes = (hash64_t*)d_dag;
copy(dag_nodes[node_index].uint4s, dag_node.uint4s, 4);
}
Expand Down

0 comments on commit ce52c74

Please sign in to comment.