Skip to content

Commit

Permalink
Shifting 4byte then casting to 8byte may result in unexpected behavior (
Browse files Browse the repository at this point in the history
#494)

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
  • Loading branch information
Alan-Jowett committed May 25, 2024
1 parent 31f9f9e commit f739036
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vm/ubpf_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ ubpf_mark_shadow_stack(
for (size_t test_bit = offset; test_bit < offset + size; test_bit++) {
// Convert test_bit into offset + mask to test against the shadow stack.
size_t bit_offset = test_bit / 8;
size_t bit_mask = 1 << (test_bit % 8);
size_t bit_mask = 1ull << (test_bit % 8);
shadow_stack[bit_offset] |= bit_mask;
}
}
Expand Down Expand Up @@ -456,7 +456,7 @@ ubpf_check_shadow_stack(
for (size_t test_bit = offset; test_bit < offset + size; test_bit++) {
// Convert test_bit into offset + mask to test against the shadow stack.
size_t bit_offset = test_bit / 8;
size_t bit_mask = 1 << (test_bit % 8);
size_t bit_mask = 1ull << (test_bit % 8);
if ((shadow_stack[bit_offset] & bit_mask) == 0) {
return false;
}
Expand Down

0 comments on commit f739036

Please sign in to comment.