116 lines
3.9 KiB
Makefile
116 lines
3.9 KiB
Makefile
.PHONY: clean build upload
|
|
.SILENT:
|
|
.NOTPARALLEL:
|
|
|
|
EXECUTABLES = clang gcc uuid rsync
|
|
DEPENDENCIES := $(foreach exec,$(EXECUTABLES), $(if $(shell which $(exec) 2> /dev/null),X,$(error "No '$(exec)' in PATH, please install it and restart octopus !")))
|
|
|
|
|
|
### Generic flags
|
|
PROG= spectre
|
|
CFLAGS= -march=native
|
|
CFLAGS+= -W
|
|
CFLAGS+= -Wall
|
|
CFLAGS+= -Werror
|
|
CFLAGS+= -Wno-unused-parameter
|
|
CFLAGS+= -Wno-missing-field-initializers
|
|
LDFLAGS= -fuse-ld=lld
|
|
|
|
### Octopus flags
|
|
CCS= clang gcc
|
|
OPTIMIZATIONS= 0 1 2 3
|
|
RETPOLINE= mretpoline
|
|
UUID:= $(shell uuid)
|
|
RESULTS_FILE= results-$(UUID).log
|
|
SSH_KEY= octoupload
|
|
TIMES= 3
|
|
#FLAGS= -v
|
|
|
|
### Octopus internals
|
|
TEE= | tee -a $(RESULTS_FILE)
|
|
|
|
### Compilers
|
|
CPROGS= $(foreach C, $(CCS), $(addsuffix -$(C), $(PROG)))
|
|
|
|
### Optimizations
|
|
OPROGS= $(foreach O, $(OPTIMIZATIONS), $(addsuffix -O$(O), $(CPROGS)))
|
|
|
|
### Static
|
|
SPROGS= $(addsuffix -static, $(foreach O, $(OPTIMIZATIONS), $(addsuffix -O$(O), $(CPROGS))))
|
|
|
|
### Retpoline
|
|
## clang
|
|
# dynamic
|
|
RCPROGS= $(addsuffix -retpoline, $(filter spectre-clang%, $(OPROGS)))
|
|
# static
|
|
RSCPROGS= $(addsuffix -retpoline, $(filter spectre-clang%, $(SPROGS)))
|
|
## gcc
|
|
# dynamic
|
|
RGPROGS= $(addsuffix -retpoline, $(filter spectre-gcc%, $(OPROGS)))
|
|
# static
|
|
RSGPROGS= $(addsuffix -retpoline, $(filter spectre-gcc%, $(SPROGS)))
|
|
|
|
PROGS= $(OPROGS)
|
|
PROGS+= $(SPROGS)
|
|
PROGS+= $(RCPROGS)
|
|
PROGS+= $(RSCPROGS)
|
|
PROGS+= $(RGROGS)
|
|
PROGS+= $(RSGPROGS)
|
|
|
|
|
|
all: upload
|
|
|
|
upload: $(RESULTS_FILE)
|
|
echo -e "\033[4mUploading $^ to www.sk4.nz\033[0m"
|
|
sftp -b - -i $(SSH_KEY) -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
|
octoupload@www.sk4.nz: <<< $$'put $^'
|
|
|
|
build: $(PROGS)
|
|
|
|
%.log: build
|
|
echo -e "\033[1m\033[94m________ __";
|
|
echo "\_____ \ _____/ |_ ____ ______ __ __ ______";
|
|
echo " / | \_/ ___\ __\/ _ \\____ \| | \/ ___/";
|
|
echo "/ | \ \___| | ( <_> ) |_> > | /\___ \ ";
|
|
echo "\_______ /\___ >__| \____/| __/|____//____ >";
|
|
echo -e " \/ \/ |__| \/\033[0m";
|
|
echo -e " Samuel AUBERTIN - EURECOM\n"
|
|
echo -e "\033[4mUUID\033[0m\t\t$(UUID)" $(TEE)
|
|
echo -e "\033[4mCPU\033[0m\t\t"$$(LC_ALL=en_US.UTF-8 lscpu | grep "Model name" | cut -d":" -f 2 | sort | uniq | awk '{$$1=$$1;print}') $(TEE)
|
|
echo -e "\033[4mMicrocode\033[0m\t"$$(grep microcode /proc/cpuinfo | sort | uniq | awk '{print $$NF}') $(TEE)
|
|
echo -e "\033[4mKernel\033[0m\t\t"$$(uname -svm) $(TEE)
|
|
echo -e "\033[4mKRETPOLINE\033[0m\t"$$(cat /boot/config-$$(uname -r) | grep RETPOLINE)
|
|
echo -e "\033[4mClang\033[0m\t\t"$$(clang -v 2>&1 | head -n 1) $(TEE)
|
|
echo -e "\033[4mGCC\033[0m\t\t"$$(gcc -v 2>&1 | grep 'gcc version') $(TEE)
|
|
echo -e "\033[4mVulnerablities\033[0m" $(TEE)
|
|
LC_ALL=en_US.UTF-8 lscpu | grep Vuln | awk '{s = ""; for(i = 2; i <= NF; i++) s = s $$i " "; print "\t\t" s }' $(TEE)
|
|
echo
|
|
taskset 01 ./$(firstword $(PROGS)) -c $(TEE); \
|
|
for p in $(PROGS); do \
|
|
for t in $$(seq $(TIMES)); do \
|
|
sleep 1; \
|
|
taskset 01 ./$$p $(FLAGS) $(TEE); \
|
|
done \
|
|
done
|
|
|
|
$(OPROGS):
|
|
$(word 2, $(subst -, ,$@)) $(CFLAGS) $(LDFLAGS) -$(word 3, $(subst -, ,$@)) -o $@ $(PROG).c
|
|
|
|
$(SPROGS):
|
|
$(word 2, $(subst -, ,$@)) $(addprefix -, $(word 4, $(subst -, ,$@))) $(CFLAGS) -$(word 3, $(subst -, ,$@)) -o $@ $(PROG).c
|
|
|
|
$(RCPROGS):
|
|
$(word 2, $(subst -, ,$@)) $(CFLAGS) -mretpoline $(LDFLAGS) -z retpolineplt -$(word 3, $(subst -, ,$@)) -o $@ $(PROG).c
|
|
|
|
$(RSCPROGS):
|
|
$(word 2, $(subst -, ,$@)) $(addprefix -, $(word 4, $(subst -, ,$@))) $(CFLAGS) -mretpoline -$(word 3, $(subst -, ,$@)) -o $@ $(PROG).c
|
|
|
|
$(RGPROGS):
|
|
$(word 2, $(subst -, ,$@)) $(CFLAGS) -mfunction-return=thunk -mindirect-branch=thunk -mindirect-branch-register $(LDFLAGS) -z retpolineplt -$(word 3, $(subst -, ,$@)) -o $@ $(PROG).c
|
|
|
|
$(RSGPROGS):
|
|
$(word 2, $(subst -, ,$@)) $(addprefix -, $(word 4, $(subst -, ,$@))) $(CFLAGS) -mfunction-return=thunk -mindirect-branch=thunk -mindirect-branch-register -$(word 3, $(subst -, ,$@)) -o $@ $(PROG).c
|
|
|
|
clean:
|
|
rm -rf $(PROGS) *.log
|