Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ssprod 23814 add addl event init method #1052

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
ac2e18a
fix(driver): use `extract__egid` instread of `extract__euid` helper
Andreagit97 Dec 8, 2022
ffad57e
fix: increase the number of attempts to retrieve container info from CRI
irozzo-1A Dec 8, 2022
ff9a370
fix(driver-modern-bpf): optimize exctract__tty lookups
incertum Dec 11, 2022
352837d
cleanup(driver-bpf): optimize tty lookup
incertum Dec 11, 2022
1a02109
cleanup(driver-modern-bpf): re-use inode lookup
incertum Dec 11, 2022
01830c3
cleanup(driver-modern-bpf): add comment to tty extraction
incertum Dec 12, 2022
76bff97
cleanup(driver-modern-bpf): re-use inode lookup for sched_process_exec
incertum Dec 12, 2022
989db97
fix: set max retries to 5 when using CRI only
irozzo-1A Dec 10, 2022
1d3f296
chore(driver): support external skeleton build for modern bpf
Andreagit97 Dec 7, 2022
4535cd8
doc: improve cmake comments
Andreagit97 Dec 9, 2022
b82bc3b
docs: add documentation for the `MODERN_BPF_SKEL_DIR` option
Andreagit97 Dec 9, 2022
14f0137
fix(sinsp): format PT_ABSTIME values
gnosek Dec 7, 2022
e8ea980
update(ci): enable gh actions jobs on maintainers/ branches
Andreagit97 Dec 13, 2022
d937062
update(userspace/libscap): avoid owning events offset in test engine
jasondellaluce Dec 15, 2022
82f2f4c
fix(userspace/libsinsp/test): own events offset in test engine
jasondellaluce Dec 15, 2022
725732a
chore(userspace): manage not bundled libelf dependency adding a custo…
Andreagit97 Dec 13, 2022
258ec63
update(userspace): compute the sum of all drops in modern probe
Andreagit97 Dec 18, 2022
04a0aa8
fix(driver): drops should be considered in the total number of events…
Andreagit97 Dec 18, 2022
0fac704
update(driver): improve logging in case of failed bpf loading
Andreagit97 Dec 20, 2022
772397f
update(build): update libcurl to 7.87.0
LucaGuerra Dec 21, 2022
6f9569d
fix: handle capset_x missing thread_info
adduali1310 Dec 28, 2022
13800c9
update(build): update openssl to 1.1.1q
LucaGuerra Jan 10, 2023
0c3d243
new(driver): add a new bpf map to retrieve PPM_SC codes
Andreagit97 Dec 22, 2022
3e825d4
new: implement generic events support in modern bpf probe
Andreagit97 Dec 22, 2022
1b54028
fix(userspace/libsinsp): avoid exception failure on unknown k8s node …
jasondellaluce Jan 16, 2023
cea6078
fix: correctly free the state in modern bpf probe
Andreagit97 Jan 9, 2023
453cd0e
new: support multiple CPUs per buffer
Andreagit97 Jan 13, 2023
8b38418
update: propagate support to scap-open
Andreagit97 Jan 13, 2023
ff44778
update: propagate support to sinsp
Andreagit97 Jan 13, 2023
88c7af6
update: set online_only as default in scap-open
Andreagit97 Jan 13, 2023
5076613
tests: add new test suite for the modern probe
Andreagit97 Jan 13, 2023
f4b199f
fix(test): fixed modern bpf tests build.
FedeDP Jan 16, 2023
41ddb69
fix: handle unshare_setns_x missing thread_info
adduali1310 Jan 24, 2023
0b3c41d
chore: cleanup thread_info nullpointer checks in parsers.cpp
adduali1310 Jan 24, 2023
333394b
fix(userspace/libscap): release resources on return
jasondellaluce Jan 27, 2023
2fb9b3c
update(userspace): narrow down buf boundaries
jasondellaluce Jan 27, 2023
3e6aa6e
chore(ci): add fake `test-drivers-x86` job.
FedeDP Jan 31, 2023
35702f2
fix(libcurl): set path to ca-certificates at build time for libcurl
alacuku Feb 9, 2023
9defcf2
cleanup(libsinsp,libscap,libpman): cleanups, fixes for return values,…
LucaGuerra Feb 16, 2023
cc03a01
fix(libscap): more readable cleanup in expand_buffer
LucaGuerra Feb 16, 2023
4795126
fix(libsinsp): do not attempt to free the storage buffer that will be…
LucaGuerra Feb 16, 2023
4b9d30c
update(libsinsp): check gmtime as well
LucaGuerra Feb 16, 2023
40a8d1a
Update userspace/libsinsp/threadinfo.cpp
LucaGuerra Feb 16, 2023
c2caaef
Update userspace/libsinsp/threadinfo.cpp
LucaGuerra Feb 16, 2023
43ade77
Update userspace/libsinsp/threadinfo.cpp
LucaGuerra Feb 16, 2023
95e61d0
Update userspace/libsinsp/threadinfo.cpp
LucaGuerra Feb 16, 2023
c43e2c8
Update userspace/libsinsp/threadinfo.cpp
LucaGuerra Feb 16, 2023
e447472
Update userspace/libsinsp/threadinfo.cpp
LucaGuerra Feb 16, 2023
ad8feb7
update(chisel): skip invalid fd tables
LucaGuerra Feb 16, 2023
f0ae10c
update(libsinsp): error if it's not possible to store the last event
LucaGuerra Feb 16, 2023
064bc75
fix(libpman): fix fclose
incertum Feb 16, 2023
abcacf9
update(libsinsp): fix reduced_ variable names
LucaGuerra Feb 16, 2023
01ad103
fix(driver): fix build on linux-6.2
hhoffstaette Feb 21, 2023
5a7193c
fix(driver/bpf): fixed bpf probe build on kernel >= 6.2
FedeDP Feb 22, 2023
4c7e2ea
fix(bpf): fixed a couple of clang15 verifier issues.
FedeDP Feb 1, 2023
1127020
update(driver): updated API_VERSION to 3.0.1 since there were bugfixes.
FedeDP Feb 23, 2023
49a1fed
fix(userspace/libsinsp): correct inizialization of m_flags
therealbobo Mar 9, 2023
6b98d41
refactor(userspace): moved flags to args
therealbobo Mar 9, 2023
c4b939e
cleanup(libsinsp,libscap,libpman): cleanups, fixes for return values,…
LucaGuerra Feb 16, 2023
035c86b
Enhancements to initial scan of /proc, for supportability
jcpittman144 Jun 16, 2021
826df27
Track container user info and expose via user.name
mstemm May 16, 2022
bdf0d26
keep lookup history when refreshing cache
VadimZy May 18, 2022
c77c752
code reformat, update for logging
VadimZy May 18, 2022
c30fa38
Add procfs_utils.ut.cpp to the test binary
gnosek Jul 16, 2021
2849c90
Remove valijson support
gnosek Feb 14, 2022
5eca840
Restore setters used in tests
gnosek Mar 17, 2022
62adb70
Make sinsp remove_inactive_threads() method public (#54)
jcpittman144 May 4, 2022
5e2816f
Allow enabling/disabling individual container engines on startup
gnosek Jan 27, 2022
5518104
Add special case code to work around syscall default behavior
jcpittman144 Dec 20, 2021
dbaa2ea
Changes needed for Sysdig agent to support aarch64 (64-bit ARM) and s…
jcpittman144 Sep 20, 2021
1fff512
Compile eBPF probe with -Wno-unknown-attributes
jcpittman144 Feb 15, 2022
641cd57
perf(sinsp): populate cmdline when setting threadinfo command args to…
VadimZy Feb 24, 2022
f021921
fix(driver): silence drop enter/exit event delayed insert messages (#38)
iurly Feb 28, 2022
1a29187
Fix after 9768501685867b2701ea196eb52a8ace9be3d3e1
gnosek Mar 16, 2022
ca0b1df
Get CRI image metadata both from image and imageRef
gnosek Mar 25, 2022
e91bafa
Fix CRI image tag detection (#50)
gnosek Apr 15, 2022
e6684fd
Workaround Linux on ARM event-generation deficiencies
jcpittman144 Mar 13, 2022
d731129
Enable CLONE_EXIT_TO_CHILD workaround on s390x
jcpittman144 Mar 17, 2022
42eff2e
Fix logic to recognize and avoid reporting expected TID collisions
jcpittman144 Mar 31, 2022
f08d3f2
CI with github actions
deepskyblue86 Mar 25, 2022
e14e7a5
Workaround for `fatal: unsafe repository (REPO is owned by someone el…
gnosek Apr 14, 2022
d6bfb1d
Fix __STDC_FORMAT_MACROS issue
deepskyblue86 May 20, 2022
161f3ea
remove redundant procfs_utils.ut.cpp
mstemm Jun 9, 2022
7840ec1
Turn off gvisor support when building libs
mstemm Jun 9, 2022
ea025ac
Incorporate ARM support changes from upstream falcosecurity/libs repo…
jcpittman144 Jul 13, 2022
4fad654
refactor(libsinsp/container): introduce sinsp_container_lookup class
deepskyblue86 Jun 15, 2022
4fceb41
Additional build changes
nathan-b Aug 1, 2022
5130dbb
Retain m_sysdig_agent_conf, was removed upstream
mstemm Oct 11, 2022
3666a12
Merge upstream pr 688 (#121)
mstemm Nov 2, 2022
cc5d3dd
Revert "Merge upstream pr 688 (#121)" (#122)
mstemm Nov 3, 2022
ed544ca
[SMAGENT-4237] Remove dead LIBSINSP_CPUARCH_THREAD_EVENT_BUG code (#126)
jcpittman144 Nov 11, 2022
b083509
Add container engine fix back (#128)
mstemm Nov 17, 2022
3035c20
[falcosecurity#677] container users and groups from process root (#127)
deepskyblue86 Nov 24, 2022
4b49817
fix(scap): don't assume __always_inline is defined
gnosek Dec 2, 2022
ebe9b77
[SMAGENT-4309] Remove obsolete function reinit_thread_from_proc() (#134)
jcpittman144 Dec 6, 2022
af7f4ff
Add const_expr_visitor, use it when compiling/cloning/stringing (#146)
mstemm Jan 20, 2023
54cde1e
Add extra include directories
gnosek Jan 18, 2023
8c9de3f
new(sinsp): Add euid to execve/execveat exit events
gnosek Jun 10, 2022
f985c58
Resolve build errors from 0.10.4 merge
greyhame-s Mar 8, 2023
5565bba
fix(driver): fixed `PPM_SC_PIDFD_GET_FD` and `PPM_SC_PIDFD_GETFD`.
FedeDP Mar 8, 2023
fde58bc
cleanup(driver,libscap): revert back breaking change in #948.
FedeDP Mar 9, 2023
a12cd5b
[falcosecurity#803] update(userspace/libsinsp): rely on proc root for…
deepskyblue86 Dec 21, 2022
1e4cb08
[SMAGENT-4559] Check struct passwd members for null pointers (#152)
wigol Feb 23, 2023
8c893eb
[smagent-4642] Changes to prepare for TBB upgrade (#161)
federico-sysdig Mar 19, 2023
ebb1753
update(driver): remove UF_ALWAYS_DROP from mmap
deepskyblue86 Mar 23, 2023
d6af955
Ssprod 23324 add filtercheck testability improvements (#165)
mstemm Mar 28, 2023
c5a503b
fix(libsinsp,libscap): remove legacy references to is_windows
LucaGuerra Mar 10, 2023
46a8bb3
fix(scap): properly detect threads in child pidns
gnosek Feb 7, 2023
b2657fa
fix(scap): simplify pidns_start_ts logic in /proc scan
gnosek Feb 6, 2023
6f55850
Resolve falcosecurity/libs#932, use /proc/1/cmdline for boot/procfs c…
happy-dude Mar 24, 2023
dba2e32
Resolve falcosecurity#932, use btime from /proc/stat for boot time
happy-dude Mar 24, 2023
898e7d7
Use SECOND_TO_NS in rest of userspace/libscap/linux/scap_procs.c
happy-dude Mar 27, 2023
7f47071
chore(scap_kmod): reduce variable scope
deepskyblue86 Mar 3, 2023
a41deb4
Pass scap_open_args to scap_open_nodriver_int
gnosek Mar 20, 2023
ef8b089
cleanup(scap): decouple limited /proc scan from nodriver engine
gnosek Mar 20, 2023
dc3d6bd
new(scap): enable full /proc scan for nodriver engine
gnosek Mar 20, 2023
13bcf92
new(scap): support no_events mode for gVisor
gnosek Mar 13, 2023
e213ca6
fix(scap): Use precise boot time for BPF engines
gnosek Apr 7, 2023
609e1d0
Add addl(test-only) way to initialize events, setting errorcode
mstemm Apr 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI Build
on:
pull_request:
branches: [dev]

jobs:
check-build:

strategy:
matrix:
flavor: [ regular, bundled-deps, with-chisels, minimal ]
include:
- flavor: regular
build-args: '-DBUILD_BPF=On -DUSE_BUNDLED_DEPS=False -DUSE_BUNDLED_VALIJSON=True'
- flavor: bundled-deps
build-args: '-DBUILD_BPF=On -DUSE_BUNDLED_DEPS=True'
- flavor: with-chisels
build-args: '-DBUILD_BPF=On -DWITH_CHISEL=True'
- flavor: minimal
build-args: '-DMINIMAL_BUILD=True'

runs-on: ubuntu-20.04
container: ubuntu:20.04

steps:
- name: Setup dependencies
run: |
apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
build-essential \
clang \
llvm \
git \
libncurses-dev \
pkg-config \
autoconf \
automake \
libtool \
libelf-dev \
wget \
libb64-dev \
libc-ares-dev \
libcurl4-openssl-dev \
libssl-dev \
libtbb-dev \
libjq-dev \
libjsoncpp-dev \
libgrpc++-dev \
protobuf-compiler-grpc \
libgtest-dev \
libprotobuf-dev \
libre2-dev \
linux-headers-$(uname -r) \
&& apt-get clean
env:
DEBIAN_FRONTEND: noninteractive

- name: "Allow agent-libs repo access, ref: https://github.com/actions/checkout/issues/760"
run: git config --global --add safe.directory /__w/agent-libs/agent-libs

- name: Checkout
uses: actions/checkout@v3

- name: Build ${{ matrix.flavor }}
run: |
rm -rf build
mkdir -p build
cd build
cmake ${{ matrix.build-args }} -DBUILD_LIBSCAP_GVISOR=OFF ..
KERNELDIR=/lib/modules/$(uname -r)/build make -j$(nproc)
make run-unit-tests
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- 'release/**'
- 'maintainers/**'
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -161,6 +162,15 @@ jobs:
KERNELDIR=/lib/modules/$(ls /lib/modules)/build make -j4
make run-unit-tests

test-drivers-x86:
name: test-drivers-x86 😇 (bundled_deps)
runs-on: ubuntu-22.04
needs: paths-filter
if: false
steps:
- name: Fake test
run: echo "skipped"

build-and-test-modern-bpf-x86:
name: build-and-test-modern-bpf-x86 😇 (bundled_deps)
runs-on: ubuntu-22.04
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ make ProbeSkeleton

> __Please note__: these are not the requirements to use the BPF probe but to build it from source!

As you have seen the modern bpf probe has strict requirements to be built that maybe are not easy to satisfy on old machines. The workaround you can use is to build the probe skeleton on a recent machine and than link it during the building phase on an older machine. To do that you have to use the cmake variable `MODERN_BPF_SKEL_DIR`. Supposing you have built the skeleton under the directory `/tmp/skel-dir`, you should use the option in this way:

```bash
cmake -DUSE_BUNDLED_DEPS=ON -DBUILD_LIBSCAP_MODERN_BPF=ON -DMODERN_BPF_SKEL_DIR="/tmp/skel-dir" -DBUILD_LIBSCAP_GVISOR=OFF ..
```

### gVisor support

Libscap contains additional library functions to allow integration with system call events coming from [gVisor](https://gvisor.dev).
Expand Down
5 changes: 3 additions & 2 deletions cmake/modules/curl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ else()
curl
PREFIX "${PROJECT_BINARY_DIR}/curl-prefix"
DEPENDS openssl zlib
URL "https://github.com/curl/curl/releases/download/curl-7_84_0/curl-7.84.0.tar.bz2"
URL_HASH "SHA256=702fb26e73190a3bd77071aa146f507b9817cc4dfce218d2ab87f00cd3bc059d"
URL "https://github.com/curl/curl/releases/download/curl-7_87_0/curl-7.87.0.tar.bz2"
URL_HASH "SHA256=5d6e128761b7110946d1276aff6f0f266f2b726f5e619f7e0a057a474155f307"
CONFIGURE_COMMAND
./configure
${CURL_SSL_OPTION}
Expand Down Expand Up @@ -73,6 +73,7 @@ else()
--without-libpsl
--without-nghttp2
--without-libssh2
--with-ca-path=/etc/ssl/certs/
--disable-threaded-resolver
--without-brotli
--without-zstd
Expand Down
6 changes: 6 additions & 0 deletions cmake/modules/libelf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ option(USE_BUNDLED_LIBELF "Enable building of the bundled libelf" ${USE_BUNDLED_

if(LIBELF_INCLUDE)
# we already have LIBELF
# We add a custom target, in this way we can always depend on `libelf`
# without distinguishing between "bundled" and "not-bundled" case
add_custom_target(libelf)
elseif(NOT USE_BUNDLED_LIBELF)
find_path(LIBELF_INCLUDE elf.h PATH_SUFFIXES elf)
find_library(LIBELF_LIB NAMES libelf.a libelf.so)
Expand All @@ -13,6 +16,9 @@ elseif(NOT USE_BUNDLED_LIBELF)
else()
message(FATAL_ERROR "Couldn't find system libelf")
endif()
# We add a custom target, in this way we can always depend on `libelf`
# without distinguishing between "bundled" and "not-bundled" case
add_custom_target(libelf)
else()
set(LIBELF_SRC "${PROJECT_BINARY_DIR}/libelf-prefix/src")
set(LIBELF_INCLUDE "${LIBELF_SRC}/libelf/libelf")
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/openssl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ else()

ExternalProject_Add(openssl
PREFIX "${PROJECT_BINARY_DIR}/openssl-prefix"
URL "https://github.com/openssl/openssl/archive/OpenSSL_1_1_1p.tar.gz"
URL_HASH "SHA256=cd0cce1de6c9a6da8f83ba7ae210a3662eab21c4df7aff30149597797b2ceac9"
URL "https://github.com/openssl/openssl/archive/OpenSSL_1_1_1q.tar.gz"
URL_HASH "SHA256=0686897afd3a08223760db73d8034550401b53ffc545798d7ca476564f80315e"
CONFIGURE_COMMAND ./config no-shared --prefix=${OPENSSL_INSTALL_DIR}
BUILD_COMMAND ${CMD_MAKE}
BUILD_IN_SOURCE 1
Expand Down
2 changes: 1 addition & 1 deletion driver/API_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0
3.0.1
2 changes: 1 addition & 1 deletion driver/SCHEMA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.3.0
1 change: 1 addition & 0 deletions driver/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ $(obj)/probe.o: $(src)/probe.c \
-fno-jump-tables \
-fno-stack-protector \
-Wno-tautological-compare \
-Wno-unknown-attributes \
-O2 -g -emit-llvm -c $< -o $(patsubst %.o,%.ll,$@)
$(LLC) -march=bpf -filetype=obj -o $@ $(patsubst %.o,%.ll,$@)
18 changes: 18 additions & 0 deletions driver/bpf/filler_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ or GPL2.txt for full copies of the license.
#include <linux/in.h>
#include <linux/fdtable.h>
#include <linux/net.h>
/* SYSDIG -- Fix Little-Endian assumptions */
#include <endian.h>

#include "../ppm_flag_helpers.h"
#include "builtins.h"
Expand Down Expand Up @@ -447,6 +449,8 @@ static __always_inline u32 bpf_compute_snaplen(struct filler_data *data,
if (lookahead_size >= 5) {
u32 buf = *(u32 *)&get_buf(0);

/* SYSDIG -- Fix Little-Endian assumptions */
#if __BYTE_ORDER == __LITTLE_ENDIAN
if (buf == 0x20544547 || // "GET "
buf == 0x54534F50 || // "POST"
buf == 0x20545550 || // "PUT "
Expand All @@ -457,6 +461,20 @@ static __always_inline u32 bpf_compute_snaplen(struct filler_data *data,
(buf == 0x50545448 && data->buf[(data->state->tail_ctx.curoff + 4) & SCRATCH_SIZE_HALF] == '/')) { // "HTTP/"
return 2000;
}
#elif __BYTE_ORDER == __BIG_ENDIAN
if (buf == 0x47455420 || // "GET "
buf == 0x504F5354 || // "POST"
buf == 0x50555420 || // "PUT "
buf == 0x44454C45 || // "DELE"
buf == 0x54524143 || // "TRAC"
buf == 0x434F4E4E || // "CONN"
buf == 0x4F505449 || // "OPTI"
(buf == 0x48545450 && data->buf[(data->state->tail_ctx.curoff + 4) & SCRATCH_SIZE_HALF] == '/')) { // "HTTP/"
return 2000;
}
#else
#error UNDEFINED __BYTE_ORDER
#endif
}
}

Expand Down
53 changes: 35 additions & 18 deletions driver/bpf/fillers.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static __always_inline int __bpf_##x(struct filler_data *data); \
__bpf_section(TP_NAME "filler/" #x) \
static __always_inline int bpf_##x(void *ctx) \
{ \
struct filler_data data; \
struct filler_data data = {0}; \
int res; \
\
res = init_filler_data(ctx, &data, is_syscall); \
Expand Down Expand Up @@ -288,7 +288,7 @@ FILLER_RAW(terminate_filler)
if (state->n_drops_scratch_map != ULLONG_MAX) {
++state->n_drops_scratch_map;
}
break;
break;
default:
bpf_printk("Unknown filler res=%d event=%d curarg=%d\n",
state->tail_ctx.prev_res,
Expand Down Expand Up @@ -852,7 +852,12 @@ static __always_inline unsigned long bpf_get_mm_counter(struct mm_struct *mm,
{
long val;

// See 6.2 kernel commit: https://github.com/torvalds/linux/commit/f1a7941243c102a44e8847e3b94ff4ff3ec56f25
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0)
bpf_probe_read(&val, sizeof(val), &mm->rss_stat.count[member]);
#else
bpf_probe_read(&val, sizeof(val), &mm->rss_stat[member].count);
#endif
if (val < 0)
val = 0;

Expand Down Expand Up @@ -1725,10 +1730,9 @@ static __always_inline int bpf_ppm_get_tty(struct task_struct *task)
struct signal_struct *sig;
struct tty_struct *tty;
struct tty_driver *driver;
int major;
int minor_start;
int index;
int tty_nr = 0;
int major = 0;
int minor_start = 0;
int index = 0;

sig = _READ(task->signal);
if (!sig)
Expand All @@ -1738,18 +1742,15 @@ static __always_inline int bpf_ppm_get_tty(struct task_struct *task)
if (!tty)
return 0;

index = _READ(tty->index);

driver = _READ(tty->driver);
if (!driver)
return 0;

index = _READ(tty->index);
major = _READ(driver->major);
minor_start = _READ(driver->minor_start);

tty_nr = new_encode_dev(MKDEV(major, minor_start) + index);

return tty_nr;
return new_encode_dev(MKDEV(major, minor_start) + index);
}

static __always_inline struct pid *bpf_task_pid(struct task_struct *task)
Expand Down Expand Up @@ -2317,7 +2318,7 @@ FILLER(proc_startupdate, true)
arg_start = _READ(mm->arg_start);
args_len = arg_end - arg_start;

if (args_len) {
if (args_len > 0) {
if (args_len > ARGS_ENV_SIZE_MAX)
args_len = ARGS_ENV_SIZE_MAX;

Expand All @@ -2344,7 +2345,7 @@ FILLER(proc_startupdate, true)
case PPME_SYSCALL_EXECVE_19_X:
val = bpf_syscall_get_argument(data, 1);
break;

case PPME_SYSCALL_EXECVEAT_X:
val = bpf_syscall_get_argument(data, 2);
break;
Expand All @@ -2362,14 +2363,14 @@ FILLER(proc_startupdate, true)
args_len = 0;
}

if (args_len) {
if (args_len > 0) {
int exe_len;

exe_len = bpf_probe_read_str(&data->buf[data->state->tail_ctx.curoff & SCRATCH_SIZE_HALF],
SCRATCH_SIZE_HALF,
&data->buf[data->state->tail_ctx.curoff & SCRATCH_SIZE_HALF]);

if (exe_len == -EFAULT)
if (exe_len < 0)
return PPM_FAILURE_INVALID_USER_MEMORY;

/*
Expand All @@ -2380,11 +2381,15 @@ FILLER(proc_startupdate, true)
if (res != PPM_SUCCESS)
return res;

args_len -= exe_len;
if (args_len < 0)
return PPM_FAILURE_INVALID_USER_MEMORY;

/*
* Args
*/
data->curarg_already_on_frame = true;
res = __bpf_val_to_ring(data, 0, args_len - exe_len, PT_BYTEBUF, -1, false);
res = __bpf_val_to_ring(data, 0, args_len, PT_BYTEBUF, -1, false);
if (res != PPM_SUCCESS)
return res;
} else {
Expand Down Expand Up @@ -2797,6 +2802,7 @@ FILLER(execve_family_flags, true)
bool exe_writable = false;
bool exe_upper_layer = false;
uint32_t flags = 0;
kuid_t euid;

if(inode)
{
Expand Down Expand Up @@ -2854,7 +2860,12 @@ FILLER(execve_family_flags, true)

/* Parameter 26: exe_file mtime (last modification time, epoch value in nanoseconds) (type: PT_ABSTIME) */
time = _READ(inode->i_mtime);
return bpf_val_to_ring_type(data, bpf_epoch_ns_from_time(time), PT_ABSTIME);
res = bpf_val_to_ring_type(data, bpf_epoch_ns_from_time(time), PT_ABSTIME);
CHECK_RES(res);

/* Parameter 27: uid */
euid = _READ(cred->euid);
return bpf_val_to_ring_type(data, euid.val, PT_UINT32);
}

FILLER(sys_accept4_e, true)
Expand Down Expand Up @@ -6473,6 +6484,7 @@ FILLER(sched_prog_exec_4, false)
bool exe_writable = false;
bool exe_upper_layer = false;
uint32_t flags = 0;
kuid_t euid;

if(inode)
{
Expand Down Expand Up @@ -6530,7 +6542,12 @@ FILLER(sched_prog_exec_4, false)

/* Parameter 26: exe_file mtime (last modification time, epoch value in nanoseconds) (type: PT_ABSTIME) */
time = _READ(inode->i_mtime);
return bpf_val_to_ring_type(data, bpf_epoch_ns_from_time(time), PT_ABSTIME);
res = bpf_val_to_ring_type(data, bpf_epoch_ns_from_time(time), PT_ABSTIME);
CHECK_RES(res);

/* Parameter 27: uid */
euid = _READ(cred->euid);
return bpf_val_to_ring_type(data, euid.val, PT_UINT32);
}
#endif

Expand Down
Loading