Files
doos/audit/CVE-2016-5195/reproduce.sh
T
2026-10-23 23:42:00 +02:00

26 lines
975 B
Bash
Executable File

#!/usr/bin/env bash
# CVE-2016-5195 (Dirty COW): kernel version against the fixed release. No exploit code.
set -u
skip() { echo "SKIP: $*"; exit 0; }
fail() { echo "FAIL: $*"; exit 1; }
pass() { echo "PASS: $*"; exit 0; }
ver=$(uname -r | grep -oE '^[0-9]+\.[0-9]+(\.[0-9]+)?')
major=$(echo "$ver" | cut -d. -f1)
minor=$(echo "$ver" | cut -d. -f2)
patch=$(echo "$ver" | cut -d. -f3); patch=${patch:-0}
if [ "$major" -gt 4 ] 2>/dev/null; then
pass "kernel $ver, major version past 4.x, long past the Dirty COW fix (4.8.3)"
fi
if [ "$major" -eq 4 ] && [ "$minor" -gt 8 ]; then
pass "kernel $ver is past 4.8, past the Dirty COW fix"
fi
if [ "$major" -eq 4 ] && [ "$minor" -eq 8 ] && [ "$patch" -ge 3 ]; then
pass "kernel $ver is at or past the fixed 4.8.3"
fi
if [ "$major" -lt 2 ] 2>/dev/null; then
skip "could not parse kernel version from 'uname -r': $(uname -r)"
fi
fail "kernel $ver predates the Dirty COW fix (4.8.3); this bug has existed since 2.6.22"