-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start building standalone falco kernel modules. (#789)
* Start building standalone falco kernel modules. falcosecurity/falco#215 pointed out a problem with compatibility between latest sysdig kernel module and falco 0.5.0. The (newer) driver had different events than falco was expecting, causing a crash. To fix this, I'm changing falco to package its own driver. It was already building its own driver, but the remaining changes are to change the device name from sysdig to falco, module falco-probe, etc. These changes will allow for automatically building the falco-probe kernel module on a variety of kernel platforms and running sysdig-probe-loader (under the name falco-probe-loader) to get a module as needed. While doing this, merge the nearly identical build_{falco,sysdig,sysdigcloud} functions into build_probe. It now does the work of checking out the right code based on the PROBE_* variables, runs make driver from the main code repository, and verifies it can be loaded. * Add autoconf for falco builds. The falco builds need autoconf so add it to the set of installed yum packages.
- Loading branch information
Showing
4 changed files
with
46 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ RUN yum -y install \ | |
git \ | ||
gcc \ | ||
gcc-c++ \ | ||
autoconf \ | ||
make \ | ||
cmake \ | ||
libdtrace-ctf \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ RUN yum -y install \ | |
git \ | ||
gcc \ | ||
gcc-c++ \ | ||
autoconf \ | ||
make \ | ||
cmake \ | ||
libdtrace-ctf \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,106 +29,65 @@ if [ ! -d $BASEDIR/output ]; then | |
mkdir $BASEDIR/output | ||
fi | ||
|
||
function build_probe { | ||
if [ "$PROBE_NAME" = "sysdig-probe" ]; then | ||
build_sysdig | ||
elif [ "$PROBE_NAME" = "sysdigcloud-probe" ]; then | ||
build_sysdigcloud | ||
else | ||
exit 1 | ||
fi | ||
} | ||
|
||
function build_sysdig { | ||
|
||
if [ ! -f $BASEDIR/output/$PROBE_NAME-$PROBE_VERSION-$ARCH-$KERNEL_RELEASE-$HASH.ko ] || [ ! -f $BASEDIR/output/$PROBE_NAME-$PROBE_VERSION-$ARCH-$KERNEL_RELEASE-$HASH_ORIG.ko ]; then | ||
|
||
echo Building $PROBE_NAME-$PROBE_VERSION-$ARCH-$KERNEL_RELEASE-$HASH.ko [${FUNCNAME[1]}] | ||
|
||
if [ ! -d sysdig ]; then | ||
git clone [email protected]:draios/sysdig.git | ||
fi | ||
if [ $PROBE_NAME = "sysdigcloud-probe" ]; then | ||
PROBE_REPO_NAME="agent" | ||
else | ||
PROBE_REPO_NAME=$(echo $PROBE_NAME | cut -f1 -d-) | ||
fi | ||
|
||
cd sysdig | ||
git checkout master | ||
# The UEK builder container doesn't have git credentials | ||
# It relies on the non-UEK builds doing the pull earlier | ||
if [[ ! "$KERNEL_TYPE" =~ "UEK" ]]; then | ||
git pull | ||
fi | ||
git checkout $PROBE_VERSION | ||
make -C driver clean || true | ||
rm -rf build || true | ||
mkdir build | ||
cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release -DSYSDIG_VERSION=$PROBE_VERSION .. | ||
make driver | ||
strip -g driver/$PROBE_NAME.ko | ||
function update_code_for { | ||
repo=$1 | ||
if [ ! -d $repo ]; then | ||
git clone [email protected]:draios/$repo.git | ||
fi | ||
|
||
KO_VERSION=$(/sbin/modinfo driver/$PROBE_NAME.ko | grep vermagic | tr -s " " | cut -d " " -f 2) | ||
if [ "$KO_VERSION" != "$KERNEL_RELEASE" ]; then | ||
echo "Corrupted probe, KO_VERSION " $KO_VERSION ", KERNEL_RELEASE " $KERNEL_RELEASE | ||
exit 1 | ||
fi | ||
cd $repo | ||
git checkout master | ||
# The UEK builder container doesn't have git credentials | ||
# It relies on the non-UEK builds doing the pull earlier | ||
if [[ ! "$KERNEL_TYPE" =~ "UEK" ]]; then | ||
git pull | ||
fi | ||
|
||
cp driver/$PROBE_NAME.ko $BASEDIR/output/$PROBE_NAME-$PROBE_VERSION-$ARCH-$KERNEL_RELEASE-$HASH.ko | ||
cp driver/$PROBE_NAME.ko $BASEDIR/output/$PROBE_NAME-$PROBE_VERSION-$ARCH-$KERNEL_RELEASE-$HASH_ORIG.ko | ||
if [ $PROBE_REPO_NAME = $repo ]; then | ||
git checkout $PROBE_VERSION | ||
else | ||
echo Skipping $PROBE_NAME-$PROBE_VERSION-$ARCH-$KERNEL_RELEASE-$HASH.ko \(already built\) | ||
git checkout $PROBE_REPO_NAME/$PROBE_VERSION | ||
fi | ||
|
||
cd $BASEDIR | ||
# Remove everything other than the files actually belonging to | ||
# the repo. | ||
git clean -d -f -x | ||
|
||
# Reset the state of the files belonging to the repo to the | ||
# state associated with the tag. | ||
git reset --hard | ||
|
||
cd .. | ||
} | ||
|
||
function build_sysdigcloud { | ||
function build_probe { | ||
|
||
if [ ! -f $BASEDIR/output/$PROBE_NAME-$PROBE_VERSION-$ARCH-$KERNEL_RELEASE-$HASH.ko ] || [ ! -f $BASEDIR/output/$PROBE_NAME-$PROBE_VERSION-$ARCH-$KERNEL_RELEASE-$HASH_ORIG.ko ]; then | ||
|
||
echo Building $PROBE_NAME-$PROBE_VERSION-$ARCH-$KERNEL_RELEASE-$HASH.ko [${FUNCNAME[1]}] | ||
|
||
if [ ! -d sysdig ]; then | ||
git clone [email protected]:draios/sysdig.git | ||
fi | ||
|
||
if [ ! -d falco ]; then | ||
git clone [email protected]:draios/falco.git | ||
fi | ||
update_code_for sysdig | ||
|
||
if [ ! -d agent ]; then | ||
git clone [email protected]:draios/agent.git | ||
if [ $PROBE_NAME != "sysdig-probe" ]; then | ||
update_code_for falco | ||
fi | ||
|
||
cd sysdig | ||
git checkout master | ||
# The UEK builder container doesn't have git credentials | ||
# It relies on the non-UEK builds doing the pull earlier | ||
if [[ ! "$KERNEL_TYPE" =~ "UEK" ]]; then | ||
git pull | ||
if [ $PROBE_NAME = "sysdigcloud-probe" ]; then | ||
update_code_for agent | ||
fi | ||
git checkout agent/$PROBE_VERSION | ||
make -C driver clean || true | ||
rm -rf build || true | ||
cd .. | ||
|
||
cd falco | ||
git checkout master | ||
if [[ ! "$KERNEL_TYPE" =~ "UEK" ]]; then | ||
git pull | ||
fi | ||
git checkout agent/$PROBE_VERSION | ||
rm -fr build || true | ||
cd .. | ||
|
||
cd agent | ||
git checkout master | ||
if [[ ! "$KERNEL_TYPE" =~ "UEK" ]]; then | ||
git pull | ||
fi | ||
git checkout $PROBE_VERSION | ||
rm -rf build || true | ||
cd $PROBE_REPO_NAME | ||
mkdir build | ||
cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release -DAGENT_VERSION=$PROBE_VERSION .. | ||
version_name=-D$(echo $PROBE_REPO_NAME | tr [a-z] [A-Z])_VERSION | ||
|
||
cmake -DCMAKE_BUILD_TYPE=Release $version_name=$PROBE_VERSION .. | ||
make driver | ||
strip -g driver/$PROBE_NAME.ko | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters