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(modern): move args declaration at the beginning #2220

Merged
merged 1 commit into from
Jan 7, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

SEC("tp_btf/sys_enter")
int BPF_PROG(bind_e, struct pt_regs *regs, long id) {
/* Collect parameters at the beginning to easily manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long socket_fd = 0;
extract__network_args(&socket_fd, 1, regs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

SEC("tp_btf/sys_enter")
int BPF_PROG(listen_e, struct pt_regs *regs, long id) {
/* Collect parameters at the beginning to manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[2] = {0};
extract__network_args(args, 2, regs);

Expand Down Expand Up @@ -46,7 +48,9 @@ int BPF_PROG(listen_e, struct pt_regs *regs, long id) {

SEC("tp_btf/sys_exit")
int BPF_PROG(listen_x, struct pt_regs *regs, long ret) {
/* Collect parameters at the beginning to manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[2] = {0};
extract__network_args(args, 2, regs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

SEC("tp_btf/sys_enter")
int BPF_PROG(recv_e, struct pt_regs *regs, long id) {
/* Collect parameters at the beginning to manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

SEC("tp_btf/sys_enter")
int BPF_PROG(recvfrom_e, struct pt_regs *regs, long id) {
/* Collect parameters at the beginning to manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

SEC("tp_btf/sys_enter")
int BPF_PROG(recvmsg_e, struct pt_regs *regs, long id) {
/* Collect parameters at the beginning to manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long socket_fd = 0;
extract__network_args(&socket_fd, 1, regs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

SEC("tp_btf/sys_enter")
int BPF_PROG(send_e, struct pt_regs *regs, long id) {
/* Collect parameters at the beginning to manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

SEC("tp_btf/sys_enter")
int BPF_PROG(shutdown_e, struct pt_regs *regs, long id) {
/* Collect parameters at the beginning to easily manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[2] = {0};
extract__network_args(args, 2, regs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

SEC("tp_btf/sys_enter")
int BPF_PROG(socket_e, struct pt_regs *regs, long id) {
/* Collect parameters at the beginning so we can easily manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);

Expand Down Expand Up @@ -53,6 +55,12 @@ int BPF_PROG(socket_e, struct pt_regs *regs, long id) {

SEC("tp_btf/sys_exit")
int BPF_PROG(socket_x, struct pt_regs *regs, long ret) {
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);

struct ringbuf_struct ringbuf;
if(!ringbuf__reserve_space(&ringbuf, SOCKET_X_SIZE, PPME_SOCKET_SOCKET_X)) {
return 0;
Expand Down Expand Up @@ -85,10 +93,6 @@ int BPF_PROG(socket_x, struct pt_regs *regs, long ret) {
}
}

/* Collect parameters at the beginning so we can easily manage socketcalls */
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);

/* Parameter 2: domain (type: PT_ENUMFLAGS32) */
uint8_t domain = (uint8_t)args[0];
ringbuf__store_u32(&ringbuf, (uint32_t)socket_family_to_scap(domain));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

SEC("tp_btf/sys_enter")
int BPF_PROG(socketpair_e, struct pt_regs *regs, long id) {
/* Collect parameters at the beginning to manage socketcalls */
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);

Expand Down
Loading