Skip to contentSkip to conversation

instructions: using clang's static analyzer on arbitrary kernel modules

DISCUSSION Jason A. Donenfeld 1 participant 1 message Jan 3, 2020

lore
Share & tools
lore
#0 lore raw

Hi,

I figure I should document this somewhere. Here's what I've been using to run both clang's scan-build and sparse at the same time on the wireguard kernel module:

rm -rf /tmp/check-wireguard-linux
make CC=clang O=/tmp/check-wireguard-linux defconfig -j$(nproc)
printf 'CONFIG_WIREGUARD=m\nCONFIG_WIREGUARD_DEBUG=y\n' >> /tmp/check-wireguard-linux/.config
make CC=clang O=/tmp/check-wireguard-linux prepare -j$(nproc)
scan-build --use-cc=clang -maxloop 100 --view --keep-going make CC=clang O=/tmp/check-wireguard-linux drivers/net/wireguard/wireguard.ko -j$(nproc) C=2 CF="-D__CHECK_ENDIAN__"

It seems to generally work well at catching super stupid mistakes.

Regards,
Jason