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

fix(test/libsinsp_e2e): fixed libsinsp_e2e tests for more stability #2085

Merged
merged 20 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d4ca933
fix(test/libsinsp_e2e): remove multithreaded usage of sinsp inspector…
FedeDP Sep 25, 2024
5436e83
chore(test): run test synchronously on the same thread of capture unl…
FedeDP Sep 26, 2024
fc675a1
chore(test/libsinsp_e2e): more fixes.
FedeDP Sep 26, 2024
25e2d08
chore(test/libsinsp/e2e): some renamings to improve readability.
FedeDP Sep 26, 2024
0a5a79a
fix(test/libsinsp_e2e): use an `eventfd` to signal main thread that i…
FedeDP Sep 26, 2024
999d876
fix(test/libsinsp_e2e): more fixes.
FedeDP Sep 26, 2024
fb293fc
fix(userspace/libsinsp, test/libsinsp_e2e): fixed libvirt-lxc contain…
FedeDP Sep 27, 2024
016839c
chore(test/libsinsp_e2e): use an atomic for `healthcheck_helper::exit…
FedeDP Sep 27, 2024
d2a9338
chore(test/libsinsp_e2e): disable `get_procs_cpu_from_driver`.
FedeDP Sep 27, 2024
8c2e098
chore(test,userspace): properly reset docker_socket in tests since it…
FedeDP Sep 27, 2024
31378fc
fix(driver/modern_bpf): fixed cgroup paths management for path_compon…
FedeDP Sep 27, 2024
fdb1daa
chore(test/libsinsp_e2e): try harder to avoid issues in `tcp_client_s…
FedeDP Sep 27, 2024
b6dc25a
fix(test/libsinsp_e2e): only enable generic syscalls in `timestamp` t…
FedeDP Sep 27, 2024
5b14800
chore(test/libsinsp_e2e): avoid using useless atomics.
FedeDP Sep 27, 2024
93776c4
fix(test): try harder to avoid event loss.
FedeDP Sep 30, 2024
741d193
fix(userspace/libpman): try harder to avoid leaking fds.
FedeDP Sep 30, 2024
52c4d31
chore(test/libsinsp_e2e): enlarge drivers' buffer size to avoid event…
FedeDP Sep 30, 2024
b714249
fix(test/libsinsp_e2e): avoid possible heap use after free.
FedeDP Sep 30, 2024
cf084be
chore(test/libsinsp_e2e): improve test reliability.
FedeDP Oct 1, 2024
a904e2e
fix(test/libsinsp_e2e): make container_clone_nspid related tests more…
FedeDP Oct 1, 2024
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
35 changes: 34 additions & 1 deletion driver/modern_bpf/helpers/store/auxmap_store_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ static __always_inline uint16_t store_cgroup_subsys(struct auxiliary_map *auxmap
* at the end of the string, reading with `bpf_probe_read_str()`).
*
* The rationale here is to replace the string terminator '\0'
* with the '/' for every path compotent, excluding the last.
* with the '/' for every path component, excluding the last.
*
* Starting from what we have already inserted ("cpuset="),
* we want to obtain as a final result:
Expand All @@ -1323,6 +1323,39 @@ static __always_inline uint16_t store_cgroup_subsys(struct auxiliary_map *auxmap
*
* cpuset=/path_part1/path_part2\0
*/

/*
* If kernfs node is still not NULL, it means last path component retrieved
* (ie: the first one to be printed) was still not '\0' (ie: '/').
* To avoid sending a cgroup that does not start with '/', manually add it.
*
* Example:
* /user.slice/user-1000.slice/[email protected]/app.slice/app-org.gnome.Terminal.slice/vte-spawn-2f17b2eb-994e-415d-bce0-44c1447d7cd2.scope
* gets split as:
* * vte-spawn-2f17b2eb-994e-415d-bce0-44c1447d7cd2.scope\0
* * app-org.gnome.Terminal.slice\0
* * app.slice\0
* * [email protected]\0
* * user-1000.slice\0
* * user.slice\0
* Without the below fix, we would send to userspace "user.slice/user-1000.slice/..." without
* leading '/'.
*
* Counter example with "5" components + the root:
* /user.slice/user-1000.slice/[email protected]/app.slice/app-org.gnome.Terminal.slice
* gets split as:
* * app-org.gnome.Terminal.slice\0
* * app.slice\0
* * [email protected]\0
* * user-1000.slice\0
* * user.slice\0
* * \0
* In this case, we won't push the new character, instead we will push the correct string.
*/
if(kn) {
push__new_character(auxmap->data, &auxmap->payload_pos, '/');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix a bug in how modern_bpf sent cgroups, when number of paths component was greater than MAX_CGROUP_PATH_POINTERS.
For example, for

/user.slice/user-1000.slice/[email protected]/app.slice/app-org.gnome.Terminal.slice/vte-spawn-2f17b2eb-994e-415d-bce0-44c1447d7cd2.scope

that is 7 paths long (considering first one, ie: root, is returned by the kernel as an empty string), we would have returned to userspace:

user.slice/user-1000.slice/[email protected]/app.slice/app-org.gnome.Terminal.slice/vte-spawn-2f17b2eb-994e-415d-bce0-44c1447d7cd2.scope

ie: the leading / was missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

total_size++;
}
for(int k = MAX_CGROUP_PATH_POINTERS - 1; k >= 0; --k) {
if(cgroup_path_pointers[k]) {
total_size += push__charbuf(auxmap->data,
Expand Down
2 changes: 1 addition & 1 deletion test/libsinsp_e2e/capture_to_file_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TEST_F(sys_call_test, can_consume_a_capture_file) {
evt->get_direction() == SCAP_ED_OUT;
};

run_callback_t test = [](concurrent_object_handle<sinsp> inspector_handle) {
run_callback_t test = [](sinsp* inspector) {
struct stat sb;
for(int i = 0; i < 100; i++) {
stat("/tmp", &sb);
Expand Down
Loading
Loading