From 30b89c1f6ea0399ae58f6660c06b4c882f064ed1 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Fri, 14 Jul 2017 16:02:56 -0400 Subject: [PATCH] jjb: Lava: Add kretprobe fuzzing This test randomly picks a large set of symbols reported by /proc/kallsyms and activate --function (kretprobe) on them. This also has the side-effect of testing kprobe since they are used to implement kretprobes. Signed-off-by: Francis Deslauriers --- lava/baremetal-tests/kprobe-fuzzing-tests.yml | 22 ++++++++ .../lttng-baremetal-tests/kprobe-fuzzing.sh | 55 +++++++++++++++++++ scripts/lttng-baremetal-tests/lava-submit.py | 7 ++- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 lava/baremetal-tests/kprobe-fuzzing-tests.yml create mode 100755 scripts/lttng-baremetal-tests/kprobe-fuzzing.sh diff --git a/lava/baremetal-tests/kprobe-fuzzing-tests.yml b/lava/baremetal-tests/kprobe-fuzzing-tests.yml new file mode 100644 index 0000000..8867683 --- /dev/null +++ b/lava/baremetal-tests/kprobe-fuzzing-tests.yml @@ -0,0 +1,22 @@ +metadata: + format: Lava-Test Test Definition 1.0 + name: lttng-fuzzing-kprobe-test + description: "Run kprobe fuzzing test suite" +install: + git-repos: + - url: https://github.com/lttng/lttng-ci + destination: ci + branch: master + steps: + - export TMPDIR="/tmp" + - cd + - ulimit -c unlimited + - mkdir -p coredump + - echo "$(pwd)/coredump/core.%e.%p.%h.%t" > /proc/sys/kernel/core_pattern +run: + steps: + - source /root/lttngvenv/activate + - cd ci/ + - lava-test-case run-tests --shell "./scripts/lttng-baremetal-tests/kprobe-fuzzing.sh" + - tar czf coredump.tar.gz coredump + - lava-test-case-attach run-benchmarks coredump.tar.gz diff --git a/scripts/lttng-baremetal-tests/kprobe-fuzzing.sh b/scripts/lttng-baremetal-tests/kprobe-fuzzing.sh new file mode 100755 index 0000000..254123c --- /dev/null +++ b/scripts/lttng-baremetal-tests/kprobe-fuzzing.sh @@ -0,0 +1,55 @@ +#!/bin/bash -xeu +# Copyright (C) 2017 - Francis Deslauriers +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +NB_KPROBE_PER_ITER=500 +SESSION_NAME="my_kprobe_session" + +# Silence the script to avoid redirection of kallsyms to fill the screen +set +x +syms=$(awk '{print $3;}' /proc/kallsyms | sort -R) +nb_syms=$(echo "$syms" | wc -l) +set -x + +# Loop over the list of symbols and enable the symbols in groups of +# $NB_KPROBE_PER_ITER +for i in $(seq 0 "$NB_KPROBE_PER_ITER" "$nb_syms"); do + # Pick $NB_KPROBE_PER_ITER symbols to instrument, craft enable-event + # command and save them to a file. We craft the commands and executed + # them in two steps so that the pipeline can be done without the bash + # '-x' option that would fill the serial buffer because of the multiple + # pipe redirections. + set +x + echo "$syms" | head -n $((i+NB_KPROBE_PER_ITER)) | tail -n $NB_KPROBE_PER_ITER |awk '{print "lttng enable-event --kernel --function=" $1 " " $1}' > lttng-enable-event.sh + set -x + + # Print what iteration we are at + echo "$i" $((i+NB_KPROBE_PER_ITER)) + + # Destroy previous session and create a new one + lttng create "$SESSION_NAME" + + # Expect commands to fail, turn off early exit of shell script on + # non-zero return value + set +e + source ./lttng-enable-event.sh + set -e + + # Run stress util to generate some kernel activity + stress --cpu 2 --io 4 --vm 2 --vm-bytes 128M --hdd 3 --timeout 5s + + lttng list "$SESSION_NAME" + lttng destroy "$SESSION_NAME" +done diff --git a/scripts/lttng-baremetal-tests/lava-submit.py b/scripts/lttng-baremetal-tests/lava-submit.py index d2bf1ff..fc8cd3f 100644 --- a/scripts/lttng-baremetal-tests/lava-submit.py +++ b/scripts/lttng-baremetal-tests/lava-submit.py @@ -157,7 +157,7 @@ def get_config_cmd(build_device): packages=['bsdtar', 'psmisc', 'wget', 'python3', 'python3-pip', \ 'libglib2.0-dev', 'libffi-dev', 'elfutils', 'libdw-dev', \ 'libelf-dev', 'libmount-dev', 'libxml2', 'libpfm4-dev', \ - 'libnuma-dev', 'python3-dev', 'swig'] + 'libnuma-dev', 'python3-dev', 'swig', 'stress'] command = OrderedDict({ 'command': 'lava_command_run', 'parameters': { @@ -259,6 +259,11 @@ def get_kvm_tests_cmd(): 'git-repo': 'https://github.com/lttng/lttng-ci.git', 'revision': 'master', 'testdef': 'lava/baremetal-tests/destructive-tests.yml' + }, + { + 'git-repo': 'https://github.com/lttng/lttng-ci.git', + 'revision': 'master', + 'testdef': 'lava/baremetal-tests/kprobe-fuzzing-tests.yml' } ], 'timeout': 18000 -- 2.34.1