Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# top-most EditorConfig file
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[Makefile]
indent_size = 4

[*.sh]
indent_style = space
indent_size = 4

[*.rs]
indent_style = space
indent_size = 4

[{*.c,*.h}]
indent_style = space
indent_size = 2
14 changes: 0 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ concurrency:
cancel-in-progress: true

jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Check code formatting
run: cargo fmt --check

- name: Run clippy
run: cargo clippy -- -D warnings

- name: Run tests
run: cargo test

build-and-push:
runs-on: ubuntu-latest
steps:
Expand Down
108 changes: 98 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ libc = "0.2.169"
smoltcp = "0.12.0"
aya = "0.13.1"
aya-obj = "0.2.1"
pest = "2.8.1"
pest_derive = "2.8.1"
llvm-sys = "201.0.1"
docopt = "1.1.1"
signal-hook = "0.3.18"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM builder:latest as builder

FROM registry.fedoraproject.org/fedora:41
FROM registry.fedoraproject.org/fedora:42

RUN mkdir /etc/berserker

Expand Down
29 changes: 26 additions & 3 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
FROM registry.fedoraproject.org/fedora:41
FROM registry.fedoraproject.org/fedora:42

RUN dnf install -y rust cargo nasm
RUN dnf install -y \
rust \
cargo \
clippy \
rustfmt \
# for stub \
nasm \
# for script jit \
llvm-devel \
zlib-devel \
libxml2-devel \
libstdc++-static \
# for bpf \
clang \
kernel-devel \
libbpf-devel

ADD ./ /berserker/

WORKDIR /berserker/

RUN cargo build -r
RUN make -C bpf

RUN nasm -f elf64 -o stub.o stub.asm && ld -o stub stub.o

RUN cargo fmt --check

RUN cargo clippy -- -D warnings

RUN cargo build -r

RUN cargo test
2 changes: 2 additions & 0 deletions bpf/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all:
clang -g -O2 --target=bpf -D__TARGET_ARCH_x86_64 -c fentry.bpf.c -o fentry.bpf.o
26 changes: 26 additions & 0 deletions bpf/fentry.bpf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "vmlinux.h"

#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

char LICENSE[] SEC("license") = "Dual MIT/GPL";

SEC("fentry/XXX")
int BPF_PROG(fentry_XXX)
{
pid_t pid;

pid = bpf_get_current_pid_tgid() >> 32;
bpf_printk("fentry: pid = %d\n", pid);
return 0;
}

SEC("fexit/XXX")
int BPF_PROG(fexit_XXX)
{
pid_t pid;

pid = bpf_get_current_pid_tgid() >> 32;
bpf_printk("fexit: pid = %d\n", pid);
return 0;
}
9 changes: 9 additions & 0 deletions bpf/vmlinux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#if defined(__TARGET_ARCH_x86_64)
# include "vmlinux/x86_64.h"
#elif defined(__TARGET_ARCH_aarch64)
# include "vmlinux/aarch64.h"
#else
# error "Unknown target"
#endif
Loading