Compare commits

...

3 Commits

Author SHA1 Message Date
Federico Di Pierro
c986c1491f chore(docker): fixup check for HOST_ROOT.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2022-10-25 10:26:20 +02:00
Federico Di Pierro
3775dc83fc cleanup(docker): avoid linking /lib/modules to /host/lib/modules at docker image creation time.
Instead, do it in docker-entrypoint scripts, so that even users using different HOST_ROOT than "/host",
will still have a working image.

Moreover, if HOST_ROOT is set, but "$HOST_ROOT/proc" is not present,
soft link "/proc" to "HOST_ROOT/proc", to allow Falco to run.
Otherwise, scap_procs would exit with error and kill the istance.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2022-09-22 17:15:40 +02:00
Andrea Terzolo
c0c37d87f5 fix(process_events): check the return value of open_live_inspector
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-09-20 18:07:30 +02:00
6 changed files with 55 additions and 7 deletions

View File

@@ -25,4 +25,19 @@ do
ln -s "$i" "/usr/src/$base"
done
/usr/bin/falco-driver-loader "$@"
if [ -n "$HOST_ROOT" ] && [ "$HOST_ROOT" != "/" ]; then
echo "* Setting up /lib/modules links from host"
ln -s /lib/modules $HOST_ROOT/lib/modules
# If HOST_ROOT is set, but HOST_ROOT/proc does not exist
# link real /proc to HOST_ROOT/proc, so that Falco can run gracefully.
# This is mostly useful when dealing with an hypervisor, like aws Fargate,
# where the container running Falco does not need to bind-mount the host proc volume,
# and its /proc already sees all task processes because it shares the same namespace.
if [ ! -d "$HOST_ROOT/proc" ]; then
echo "* Setting up /proc links from host"
ln -s "/proc" "$HOST_ROOT/proc"
fi
fi
/usr/bin/falco-driver-loader "$@"

View File

@@ -103,8 +103,7 @@ RUN sed -e 's/time_format_iso_8601: false/time_format_iso_8601: true/' < /etc/fa
# Some base images have an empty /lib/modules by default
# If it's not empty, docker build will fail instead of
# silently overwriting the existing directory
RUN rm -df /lib/modules \
&& ln -s $HOST_ROOT/lib/modules /lib/modules
RUN rm -df /lib/modules
# debian:stable head contains binutils 2.31, which generates
# binaries that are incompatible with kernels < 4.16. So manually

View File

@@ -30,4 +30,19 @@ if [[ -z "${SKIP_DRIVER_LOADER}" ]]; then
/usr/bin/falco-driver-loader
fi
exec "$@"
if [ -n "$HOST_ROOT" ] && [ "$HOST_ROOT" != "/" ]; then
echo "* Setting up /lib/modules links from host"
ln -s /lib/modules $HOST_ROOT/lib/modules
# If HOST_ROOT is set, but HOST_ROOT/proc does not exist
# link real /proc to HOST_ROOT/proc, so that Falco can run gracefully.
# This is mostly useful when dealing with an hypervisor, like aws Fargate,
# where the container running Falco does not need to bind-mount the host proc volume,
# and its /proc already sees all task processes because it shares the same namespace.
if [ ! -d "$HOST_ROOT/proc" ]; then
echo "* Setting up /proc links from host"
ln -s "/proc" "$HOST_ROOT/proc"
fi
fi
exec "$@"

View File

@@ -96,8 +96,7 @@ RUN rm -rf /usr/bin/clang \
# Some base images have an empty /lib/modules by default
# If it's not empty, docker build will fail instead of
# silently overwriting the existing directory
RUN rm -df /lib/modules \
&& ln -s $HOST_ROOT/lib/modules /lib/modules
RUN rm -df /lib/modules
ADD falco-${FALCO_VERSION}-*.deb /
RUN dpkg -i /falco-${FALCO_VERSION}-$(uname -m).deb

View File

@@ -31,4 +31,19 @@ if [[ -z "${SKIP_DRIVER_LOADER}" ]]; then
/usr/bin/falco-driver-loader
fi
if [ -n "$HOST_ROOT" ] && [ "$HOST_ROOT" != "/" ]; then
echo "* Setting up /lib/modules links from host"
ln -s /lib/modules $HOST_ROOT/lib/modules
# If HOST_ROOT is set, but HOST_ROOT/proc does not exist
# link real /proc to HOST_ROOT/proc, so that Falco can run gracefully.
# This is mostly useful when dealing with an hypervisor, like aws Fargate,
# where the container running Falco does not need to bind-mount the host proc volume,
# and its /proc already sees all task processes because it shares the same namespace.
if [ ! -d "$HOST_ROOT/proc" ]; then
echo "* Setting up /proc links from host"
ln -s "/proc" "$HOST_ROOT/proc"
fi
fi
exec "$@"

View File

@@ -335,7 +335,12 @@ application::run_result application::process_events()
try
{
falco_logger::log(LOG_DEBUG, "Opening event source '" + source + "'\n");
open_live_inspector(src_info->inspector, source);
res = open_live_inspector(src_info->inspector, source);
if (!res.success)
{
return res;
}
if (m_state->enabled_sources.size() == 1)
{
// optimization: with only one source we don't spawn additional threads