Skip to content

Commit

Permalink
update(modern_bpf): add a missing parameter in signalfd syscalls
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <[email protected]>
Co-authored-by: Hendrik Brueckner <[email protected]>
  • Loading branch information
2 people authored and poiana committed Aug 4, 2022
1 parent beb519c commit de3dee2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ int BPF_PROG(signalfd_e,
ringbuf__store_u32(&ringbuf, 0);

/* Parameter 3: flags (type: PT_FLAGS8) */
/// TODO: this are not flags, but it is a sizemask,
/// please see here for more deatails:
/// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/signalfd.c#n302
/// We need to create 2 separate events for `signalfd` and `signalfd4`.
/* Like in the old probe we send `0`. */
ringbuf__store_u8(&ringbuf, 0);

Expand Down Expand Up @@ -74,5 +78,4 @@ int BPF_PROG(signalfd_x,
return 0;
}


/*=============================== EXIT EVENT ===========================*/
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ TEST(SyscallEnter, signalfd4E)
/* `mask` and `flags` are not catched BPF side. */
int32_t mock_fd = -1;
sigset_t mask = {0};
size_t sizemask = 0;
int flags = 7;
assert_syscall_state(SYSCALL_FAILURE, "signalfd4", syscall(__NR_signalfd4, mock_fd, &mask, flags));
assert_syscall_state(SYSCALL_FAILURE, "signalfd4", syscall(__NR_signalfd4, mock_fd, &mask, sizemask, flags));

/*=============================== TRIGGER SYSCALL ===========================*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ TEST(SyscallEnter, signalfdE)

/*=============================== TRIGGER SYSCALL ===========================*/

/* `mask` and `flags` are not caught BPF side. */
/* `mask` is not caught BPF side. */
int32_t mock_fd = -1;
sigset_t mask = {0};
int flags = 7;
assert_syscall_state(SYSCALL_FAILURE, "signalfd", syscall(__NR_signalfd, mock_fd, &mask, flags));
size_t sizemask = 0;
assert_syscall_state(SYSCALL_FAILURE, "signalfd", syscall(__NR_signalfd, mock_fd, &mask, sizemask));

/*=============================== TRIGGER SYSCALL ===========================*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ TEST(SyscallExit, signalfd4X)
/* `mask` and `flags` are not catched BPF side. */
int32_t mock_fd = -1;
sigset_t mask = {0};
size_t sizemask = 0;
int flags = 7;
assert_syscall_state(SYSCALL_FAILURE, "signalfd4", syscall(__NR_signalfd4, mock_fd, &mask, flags));
assert_syscall_state(SYSCALL_FAILURE, "signalfd4", syscall(__NR_signalfd4, mock_fd, &mask, sizemask, flags));
int64_t errno_value = -errno;

/*=============================== TRIGGER SYSCALL ===========================*/
Expand Down
6 changes: 3 additions & 3 deletions test/modern_bpf/test_suites/syscall_exit_suite/signalfd_x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ TEST(SyscallExit, signalfdX)

/*=============================== TRIGGER SYSCALL ===========================*/

/* `mask` and `flags` are not caught BPF side. */
/* `mask` is not caught BPF side. */
int32_t mock_fd = -1;
sigset_t mask = {0};
int flags = 7;
assert_syscall_state(SYSCALL_FAILURE, "signalfd", syscall(__NR_signalfd, mock_fd, &mask, flags));
size_t sizemask = 0;
assert_syscall_state(SYSCALL_FAILURE, "signalfd", syscall(__NR_signalfd, mock_fd, &mask, sizemask));
int64_t errno_value = -errno;

/*=============================== TRIGGER SYSCALL ===========================*/
Expand Down

0 comments on commit de3dee2

Please sign in to comment.