Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(bpf): add tail call to sendmmsg filler #2267

Merged
merged 1 commit into from
Feb 4, 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
51 changes: 32 additions & 19 deletions driver/bpf/fillers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4529,31 +4529,18 @@ FILLER(sys_sendmmsg_x, true) {
uint16_t size = 0;
int addrlen;
int err = 0;
int fd = 0;
int res;
long retval = bpf_syscall_get_retval(data->ctx);
int fd = bpf_syscall_get_argument(data, 0);

if(retval < 0) {
/* Parameter 1: res (type: PT_ERRNO) */
res = bpf_push_s64_to_ring(data, retval);
CHECK_RES(res);

/* Parameter 2: fd (type: PT_BYTEBUF) */
res = bpf_push_s64_to_ring(data, fd);
CHECK_RES(res);

/* Parameter 3: size (type: PT_UINT32) */
bpf_push_u32_to_ring(data, 0);
CHECK_RES(res);

/* Parameter 4: data (type: PT_BYTEBUF) */
bpf_push_empty_param(data);
CHECK_RES(res);

/* Parameter 5: tuple (type: PT_SOCKTUPLE) */
return bpf_push_empty_param(data);
bpf_tail_call(data->ctx, &tail_map, PPM_FILLER_sys_sendmmsg_x_failure);
bpf_printk("Can't tail call f_sys_sendmmsg_x_failure filler\n");
return PPM_FAILURE_BUG;
}

fd = bpf_syscall_get_argument(data, 0);

mmh_ptr = (struct mmsghdr *)bpf_syscall_get_argument(data, 1);
vlen = bpf_syscall_get_argument(data, 2);

Expand Down Expand Up @@ -4612,6 +4599,32 @@ FILLER(sys_sendmmsg_x, true) {
return res;
}

FILLER(sys_sendmmsg_x_failure, true) {
int res;

long retval = bpf_syscall_get_retval(data->ctx);
int fd = bpf_syscall_get_argument(data, 0);

/* Parameter 1: res (type: PT_ERRNO) */
res = bpf_push_s64_to_ring(data, retval);
CHECK_RES(res);

/* Parameter 2: fd (type: PT_BYTEBUF) */
res = bpf_push_s64_to_ring(data, fd);
CHECK_RES(res);

/* Parameter 3: size (type: PT_UINT32) */
bpf_push_u32_to_ring(data, 0);
CHECK_RES(res);

/* Parameter 4: data (type: PT_BYTEBUF) */
bpf_push_empty_param(data);
CHECK_RES(res);

/* Parameter 5: tuple (type: PT_SOCKTUPLE) */
return bpf_push_empty_param(data);
}

FILLER(sys_creat_e, true) {
unsigned long val;
unsigned long mode;
Expand Down
1 change: 1 addition & 0 deletions driver/ppm_fillers.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ or GPL2.txt for full copies of the license.
FN(sys_sendmsg_e) \
FN(sys_sendmsg_x) \
FN(sys_sendmmsg_x) \
FN(sys_sendmmsg_x_failure) \
FN(sys_recv_x) \
FN(sys_recvfrom_x) \
FN(sys_recvmsg_x) \
Expand Down
Loading