1 // SPDX-License-Identifier: GPL-2.0-only
3 * vdso_restorer.c - tests vDSO-based signal restore
4 * Copyright (c) 2015 Andrew Lutomirski
6 * This makes sure that sa_restorer == NULL keeps working on 32-bit
7 * configurations. Modern glibc doesn't use it under any circumstances,
8 * so it's easy to overlook breakage.
10 * 64-bit userspace has never supported sa_restorer == NULL, so this is
22 #include <sys/syscall.h>
24 /* Open-code this -- the headers are too messy to easily use them. */
25 struct real_sigaction
{
32 static volatile sig_atomic_t handler_called
;
34 static void handler_with_siginfo(int sig
, siginfo_t
*info
, void *ctx_void
)
39 static void handler_without_siginfo(int sig
)
47 struct real_sigaction sa
;
49 memset(&sa
, 0, sizeof(sa
));
50 sa
.handler
= handler_with_siginfo
;
51 sa
.flags
= SA_SIGINFO
;
52 sa
.restorer
= NULL
; /* request kernel-provided restorer */
54 if (syscall(SYS_rt_sigaction
, SIGUSR1
, &sa
, NULL
, 8) != 0)
55 err(1, "raw rt_sigaction syscall");
60 printf("[OK]\tSA_SIGINFO handler returned successfully\n");
62 printf("[FAIL]\tSA_SIGINFO handler was not called\n");
67 sa
.handler
= handler_without_siginfo
;
68 if (syscall(SYS_sigaction
, SIGUSR1
, &sa
, 0) != 0)
69 err(1, "raw sigaction syscall");
75 printf("[OK]\t!SA_SIGINFO handler returned successfully\n");
77 printf("[FAIL]\t!SA_SIGINFO handler was not called\n");