Skip to content
Closed
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
14 changes: 7 additions & 7 deletions .gitlab/kernel_matrix_testing/security_agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ kmt_run_secagent_tests_x64:
- "ubuntu_20.04"
- "ubuntu_22.04"
- "ubuntu_24.04"
- "ubuntu_24.10"
- "ubuntu_25.04"
- "amazon_4.14"
- "amazon_5.4"
- "amazon_5.10"
Expand Down Expand Up @@ -179,7 +179,7 @@ kmt_run_secagent_tests_x64_peds:
- "ubuntu_20.04"
- "ubuntu_22.04"
- "ubuntu_24.04"
- "ubuntu_24.10"
- "ubuntu_25.04"
- "amazon_4.14"
- "amazon_5.4"
- "amazon_5.10"
Expand Down Expand Up @@ -218,7 +218,7 @@ kmt_run_secagent_tests_x64_required:
parallel:
matrix:
- TAG:
- "ubuntu_24.10"
- "ubuntu_25.04"
TEST_SET: [cws_req]
after_script:
- !reference [.collect_outcomes_kmt]
Expand Down Expand Up @@ -283,7 +283,7 @@ kmt_run_secagent_tests_x64_docker:
- "ubuntu_20.04"
- "ubuntu_22.04"
- "ubuntu_24.04"
- "ubuntu_24.10"
- "ubuntu_25.04"
- "amazon_4.14"
- "amazon_5.4"
- "amazon_5.10"
Expand Down Expand Up @@ -320,7 +320,7 @@ kmt_run_secagent_tests_arm64:
- TAG:
- "ubuntu_22.04"
- "ubuntu_24.04"
- "ubuntu_24.10"
- "ubuntu_25.04"
- "amazon_5.4"
- "amazon_5.10"
- "amazon_2023"
Expand Down Expand Up @@ -356,7 +356,7 @@ kmt_run_secagent_tests_arm64_peds:
- TAG:
- "ubuntu_22.04"
- "ubuntu_24.04"
- "ubuntu_24.10"
- "ubuntu_25.04"
- "amazon_5.4"
- "amazon_5.10"
- "amazon_2023"
Expand Down Expand Up @@ -434,7 +434,7 @@ kmt_run_secagent_tests_arm64_docker:
- TAG:
- "ubuntu_22.04"
- "ubuntu_24.04"
- "ubuntu_24.10"
- "ubuntu_25.04"
- "amazon_5.4"
- "amazon_5.10"
- "amazon_2023"
Expand Down
4 changes: 2 additions & 2 deletions .gitlab/kernel_matrix_testing/system_probe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ kmt_run_sysprobe_tests_x64:
- "ubuntu_20.04"
- "ubuntu_22.04"
- "ubuntu_24.04"
- "ubuntu_24.10"
- "ubuntu_25.04"
- "amazon_4.14"
- "amazon_5.4"
- "amazon_5.10"
Expand Down Expand Up @@ -261,7 +261,7 @@ kmt_run_sysprobe_tests_arm64:
- "ubuntu_20.04"
- "ubuntu_22.04"
- "ubuntu_24.04"
- "ubuntu_24.10"
- "ubuntu_25.04"
- "amazon_4.14"
- "amazon_5.4"
- "amazon_5.10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestOOMKillProbe(t *testing.T) {
return false
}, 10*time.Second, 500*time.Millisecond, "failed to find an OOM killed process with pid %d", cmd.Process.Pid)

assert.Regexp(t, regexp.MustCompile("run-([0-9|a-z]*).scope"), result.CgroupName, "cgroup name")
assert.Regexp(t, regexp.MustCompile(`run-.+\.scope`), result.CgroupName, "cgroup name")
assert.Equal(t, result.TriggerPid, result.VictimPid, "tpid == pid")
assert.NotZero(t, result.Score, "score")
assert.Equal(t, int16(42), result.ScoreAdj, "score adj")
Expand Down
98 changes: 72 additions & 26 deletions pkg/ebpf/c/lock_contention.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,37 +350,83 @@ BPF_PERCPU_ARRAY_MAP(ranges, struct lock_range, 0);

__hidden int data_map_full;

static __always_inline int can_record(u64 *ctx, struct lock_range* range)
{
u64 addr = ctx[0];

u64 end = num_of_ranges - 1;
u64 start = 0;

struct range_loop_ctx {
u64 addr;
u64 m;
struct lock_range *test_range;
for (int i = 0; i < log2_num_of_ranges+1; i++) {
if (start > end)
return false;
u64 start;
u64 end;
struct lock_range *range;
};

m = start + ((end - start) / 2);
static int range_loop_callback(u32 index, void *data)
{
struct range_loop_ctx *ctx = data;
if (ctx->start > ctx->end)
return 1;

ctx->m = ctx->start + ((ctx->end - ctx->start) / 2);
struct lock_range *test_range = bpf_map_lookup_elem(&ranges, &ctx->m);
if (!test_range)
return 1;

if ((ctx->addr >= test_range->addr_start) && (ctx->addr <= (test_range->addr_start + test_range->range))) {
bpf_memcpy(ctx->range, test_range, sizeof(struct lock_range));
return 1;
}

test_range = bpf_map_lookup_elem(&ranges, &m);
if (!test_range)
return false;
if (ctx->addr < test_range->addr_start)
ctx->end = ctx->m - 1;
else
ctx->start = ctx->m + 1;

if ((addr >= test_range->addr_start) && (addr <= (test_range->addr_start + test_range->range))) {
bpf_memcpy(range, test_range, sizeof(struct lock_range));
return true;
}
return 0;
}

if (addr < test_range->addr_start)
end = m - 1;
else
start = m + 1;
}
static __always_inline int can_record(u64 *ctx, struct lock_range* range)
{
struct range_loop_ctx data = {
.addr = ctx[0],
.m = 0,
.start = 0,
.end = num_of_ranges - 1,
.range = range,
};

int loops_returned = bpf_loop(log2_num_of_ranges, range_loop_callback, &data, 0);
if (loops_returned < 0 || !data.range->type)
return false;

return true;

return false;
// u64 addr = ctx[0];
//
// u64 end = num_of_ranges - 1;
// u64 start = 0;
//
// u64 m;
// struct lock_range *test_range;
// for (int i = 0; i < log2_num_of_ranges+1; i++) {
// if (start > end)
// return false;
//
// m = start + ((end - start) / 2);
//
// test_range = bpf_map_lookup_elem(&ranges, &m);
// if (!test_range)
// return false;
//
// if ((addr >= test_range->addr_start) && (addr <= (test_range->addr_start + test_range->range))) {
// bpf_memcpy(range, test_range, sizeof(struct lock_range));
// return true;
// }
//
// if (addr < test_range->addr_start)
// end = m - 1;
// else
// start = m + 1;
// }
//
// return false;
}

/* lock contention flags from include/trace/events/lock.h */
Expand Down Expand Up @@ -430,7 +476,7 @@ SEC("tp_btf/contention_begin")
int tracepoint__contention_begin(u64 *ctx)
{
struct tstamp_data *pelem;
struct lock_range range;
struct lock_range range = {};

if (!can_record(ctx, &range))
return 0;
Expand Down
2 changes: 1 addition & 1 deletion pkg/ebpf/lockcontention.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
ioctlCollectLocksCmd = 0x70c13

// maximum lock ranges to track
maxTrackedRanges = 16384
maxTrackedRanges = 1024

// batch size when updating per cpu map storing lock ranges
// this value is the chunks in which we add the ranges to the per-cpu map
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/tracer/tracer_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,7 @@ func (s *TracerSuite) TestShortWrite() {
require.True(collect, ok)

require.Equal(collect, sent, conn.Monotonic.SentBytes)
}, 3*time.Second, 100*time.Millisecond, "couldn't find connection used by short write")
}, 10*time.Second, 100*time.Millisecond, "couldn't find connection used by short write")
}

func (s *TracerSuite) TestKprobeAttachWithKprobeEvents() {
Expand Down
22 changes: 22 additions & 0 deletions test/new-e2e/system-probe/config/platforms.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@
"os_version": "8.4",
"image": "rocky-8.4-x86_64.qcow2.xz",
"image_version": "20250320_7cf8bbf7"
},
"ubuntu_25.04": {
"image": "ubuntu-25.04-x86_64.qcow2.xz",
"image_version": "bryce.kahle/fix-ubuntu-oracular",
"os_name": "Ubuntu",
"os_id": "ubuntu",
"kernel": "6.14.0-33-generic",
"os_version": "25.04",
"alt_version_names": [
"plucky"
]
}
},
"arm64": {
Expand Down Expand Up @@ -510,6 +521,17 @@
"os_version": "9.4",
"image": "rocky-9.4-arm64.qcow2.xz",
"image_version": "20241209_f6a14db0"
},
"ubuntu_25.04": {
"image": "ubuntu-25.04-arm64.qcow2.xz",
"image_version": "bryce.kahle/fix-ubuntu-oracular",
"os_name": "Ubuntu",
"os_id": "ubuntu",
"kernel": "6.14.0-33-generic",
"os_version": "25.04",
"alt_version_names": [
"plucky"
]
}
}
}
Loading