On Thu, Sep 26, 2024 at 4:54 AM Puranjay Mohan <puranjay@xxxxxxxxxx> wrote: > > Add testcases to test bpf_send_signal_remote(). In these new test cases, > the main process triggers the BPF program and the forked process > receives the signals. The target process's signal handler receives a > cookie from the bpf program. > > Signed-off-by: Puranjay Mohan <puranjay@xxxxxxxxxx> > --- > .../selftests/bpf/prog_tests/send_signal.c | 133 +++++++++++++----- > .../bpf/progs/test_send_signal_kern.c | 35 ++++- > 2 files changed, 130 insertions(+), 38 deletions(-) > > diff --git a/tools/testing/selftests/bpf/prog_tests/send_signal.c b/tools/testing/selftests/bpf/prog_tests/send_signal.c > index 6cc69900b3106..beb771347a503 100644 > --- a/tools/testing/selftests/bpf/prog_tests/send_signal.c > +++ b/tools/testing/selftests/bpf/prog_tests/send_signal.c > @@ -8,17 +8,25 @@ static int sigusr1_received; > > static void sigusr1_handler(int signum) > { > - sigusr1_received = 1; > + sigusr1_received = 8; > +} > + > +static void sigusr1_siginfo_handler(int s, siginfo_t *i, void *v) > +{ > + sigusr1_received = i->si_value.sival_int; If I'm reading this correctly: typedef union sigval { int sival_int; void *sival_ptr; } sigval_t; the user space will receive 4 bytes of garbage if it reads sival_ptr instead. I think it's better to make sure bpf prog passes 8 bytes instead of 4.