Skip to content

Commit 9c1d184

Browse files
committed
feat!: drop setgid enter evts gen, testing and parsing code
As the `setgid` exit events contain all the information needed, drop `setgid` enter events generation from all drivers, and all related testing and parsing code. BREAKING CHANGE: drop `setgid` enter evts gen and parsing Signed-off-by: Leonardo Di Giovanna <[email protected]>
1 parent 7e257ce commit 9c1d184

File tree

9 files changed

+3
-98
lines changed

9 files changed

+3
-98
lines changed

driver/fillers_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
199199
[PPME_SCAPEVENT_E] = {FILLER_REF(sys_scapevent_e)},
200200
[PPME_SYSCALL_SETUID_E] = {FILLER_DISABLED},
201201
[PPME_SYSCALL_SETUID_X] = {FILLER_REF(sys_setuid_x)},
202-
[PPME_SYSCALL_SETGID_E] = {FILLER_REF(sys_autofill), 1, APT_REG, {{0}}},
202+
[PPME_SYSCALL_SETGID_E] = {FILLER_DISABLED},
203203
[PPME_SYSCALL_SETGID_X] = {FILLER_REF(sys_setgid_x)},
204204
[PPME_SYSCALL_GETUID_E] = {FILLER_DISABLED},
205205
[PPME_SYSCALL_GETUID_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},

driver/modern_bpf/programs/tail_called/events/syscall_dispatched_events/setgid.bpf.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,6 @@
88

99
#include <helpers/interfaces/fixed_size_event.h>
1010

11-
/*=============================== ENTER EVENT ===========================*/
12-
13-
SEC("tp_btf/sys_enter")
14-
int BPF_PROG(setgid_e, struct pt_regs *regs, long id) {
15-
struct ringbuf_struct ringbuf;
16-
if(!ringbuf__reserve_space(&ringbuf, SETGID_E_SIZE, PPME_SYSCALL_SETGID_E)) {
17-
return 0;
18-
}
19-
20-
ringbuf__store_event_header(&ringbuf);
21-
22-
/*=============================== COLLECT PARAMETERS ===========================*/
23-
24-
/* Parameter 1: gid (type: PT_GID) */
25-
uint32_t gid = (uint32_t)extract__syscall_argument(regs, 0);
26-
ringbuf__store_u32(&ringbuf, gid);
27-
28-
/*=============================== COLLECT PARAMETERS ===========================*/
29-
30-
ringbuf__submit_event(&ringbuf);
31-
32-
return 0;
33-
}
34-
35-
/*=============================== ENTER EVENT ===========================*/
36-
3711
/*=============================== EXIT EVENT ===========================*/
3812

3913
SEC("tp_btf/sys_exit")

test/drivers/test_suites/syscall_enter_suite/setgid_e.cpp

Lines changed: 0 additions & 37 deletions
This file was deleted.

test/libsinsp_e2e/sys_call_test.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -927,11 +927,6 @@ TEST_F(sys_call_test, getsetuid_and_gid) {
927927
++callnum;
928928
EXPECT_EQ("0", e->get_param_value_str("res", false));
929929
break;
930-
case PPME_SYSCALL_SETGID_E:
931-
++callnum;
932-
EXPECT_EQ("6566", e->get_param_value_str("gid", false));
933-
EXPECT_EQ("<NA>", e->get_param_value_str("gid"));
934-
break;
935930
case PPME_SYSCALL_SETGID_X:
936931
++callnum;
937932
EXPECT_EQ("0", e->get_param_value_str("res", false));
@@ -975,7 +970,7 @@ TEST_F(sys_call_test, getsetuid_and_gid) {
975970
FAIL() << "Cannot restore initial id state.";
976971
}
977972

978-
EXPECT_EQ(7, callnum);
973+
EXPECT_EQ(6, callnum);
979974
}
980975

981976
#ifdef __x86_64__

userspace/libpman/src/events_prog_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ event_prog_t event_prog_table[PPM_EVENT_MAX][MAX_FEATURE_CHECKS] = {
165165
[PPME_SYSCALL_UNLINK_2_X] = {{false, "unlink_x", 0}},
166166
[PPME_SYSCALL_UNLINKAT_2_E] = {{true, NULL}},
167167
[PPME_SYSCALL_UNLINKAT_2_X] = {{false, "unlinkat_x", 0}},
168-
[PPME_SYSCALL_SETGID_E] = {{false, "setgid_e", 0}},
168+
[PPME_SYSCALL_SETGID_E] = {{true, NULL}},
169169
[PPME_SYSCALL_SETGID_X] = {{false, "setgid_x", 0}},
170170
[PPME_SYSCALL_SETUID_E] = {{true, NULL}},
171171
[PPME_SYSCALL_SETUID_X] = {{false, "setuid_x", 0}},

userspace/libscap/engine/gvisor/fillers.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -874,15 +874,6 @@ int32_t fill_event_setuid_x(scap_sized_buffer scap_buf,
874874
uid);
875875
}
876876

877-
// PPME_SYSCALL_SETGID_E
878-
// Event field validity issues: none
879-
int32_t fill_event_setgid_e(scap_sized_buffer scap_buf,
880-
size_t* event_size,
881-
char* scap_err,
882-
uint32_t gid) {
883-
return scap_event_encode_params(scap_buf, event_size, scap_err, PPME_SYSCALL_SETGID_E, 1, gid);
884-
}
885-
886877
// PPME_SYSCALL_SETGID_X
887878
// Event field validity issues: none
888879
int32_t fill_event_setgid_x(scap_sized_buffer scap_buf,

userspace/libscap/engine/gvisor/fillers.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,6 @@ int32_t fill_event_setuid_x(scap_sized_buffer scap_buf,
291291
int64_t res,
292292
uint32_t uid);
293293

294-
int32_t fill_event_setgid_e(scap_sized_buffer scap_buf,
295-
size_t* event_size,
296-
char* scap_err,
297-
uint32_t gid);
298-
299294
int32_t fill_event_setgid_x(scap_sized_buffer scap_buf,
300295
size_t* event_size,
301296
char* scap_err,

userspace/libscap/engine/gvisor/parsers.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,13 +1302,6 @@ static parse_result parse_setid(uint32_t id,
13021302
}
13031303
} else {
13041304
switch(gvisor_evt.sysno()) {
1305-
case __NR_setgid:
1306-
ret.status = scap_gvisor::fillers::fill_event_setgid_e(scap_buf,
1307-
&ret.size,
1308-
scap_err,
1309-
gvisor_evt.id());
1310-
break;
1311-
13121305
case __NR_setsid:
13131306
ret.status = scap_gvisor::fillers::fill_event_setsid_e(scap_buf, &ret.size, scap_err);
13141307
break;

userspace/libsinsp/test/events_user.ut.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ TEST_F(sinsp_with_test_input, setuid_setgid) {
3333
evt = add_event_advance_ts(increasing_ts(), 1, PPME_SYSCALL_SETUID_X, 2, errno_success, 500);
3434
ASSERT_EQ(get_field_as_string(evt, "user.uid"), "500");
3535

36-
// set a new group ID
37-
evt = add_event_advance_ts(increasing_ts(), 1, PPME_SYSCALL_SETGID_E, 1, 600);
38-
// check that upon entry we have the default group ID
39-
ASSERT_EQ(get_field_as_string(evt, "group.gid"), "0");
40-
4136
// check that the group ID is updated if the call is successful
4237
evt = add_event_advance_ts(increasing_ts(), 1, PPME_SYSCALL_SETGID_X, 2, errno_success, 600);
4338
ASSERT_EQ(get_field_as_string(evt, "group.gid"), "600");
@@ -47,7 +42,6 @@ TEST_F(sinsp_with_test_input, setuid_setgid) {
4742
ASSERT_EQ(get_field_as_string(evt, "user.uid"), "500");
4843

4944
// same for group ID
50-
add_event_advance_ts(increasing_ts(), 1, PPME_SYSCALL_SETGID_E, 1, 0);
5145
evt = add_event_advance_ts(increasing_ts(), 1, PPME_SYSCALL_SETGID_X, 2, errno_failure, 0);
5246
ASSERT_EQ(get_field_as_string(evt, "group.gid"), "600");
5347
}

0 commit comments

Comments
 (0)