.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * vdso_restorer.c - tests vDSO-based signal restore |
---|
3 | 4 | * Copyright (c) 2015 Andrew Lutomirski |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify |
---|
6 | | - * it under the terms and conditions of the GNU General Public License, |
---|
7 | | - * version 2, as published by the Free Software Foundation. |
---|
8 | | - * |
---|
9 | | - * This program is distributed in the hope it will be useful, but |
---|
10 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | | - * General Public License for more details. |
---|
13 | 5 | * |
---|
14 | 6 | * This makes sure that sa_restorer == NULL keeps working on 32-bit |
---|
15 | 7 | * configurations. Modern glibc doesn't use it under any circumstances, |
---|
.. | .. |
---|
23 | 15 | |
---|
24 | 16 | #include <err.h> |
---|
25 | 17 | #include <stdio.h> |
---|
| 18 | +#include <dlfcn.h> |
---|
26 | 19 | #include <string.h> |
---|
27 | 20 | #include <signal.h> |
---|
28 | 21 | #include <unistd.h> |
---|
.. | .. |
---|
54 | 47 | int nerrs = 0; |
---|
55 | 48 | struct real_sigaction sa; |
---|
56 | 49 | |
---|
| 50 | + void *vdso = dlopen("linux-vdso.so.1", |
---|
| 51 | + RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); |
---|
| 52 | + if (!vdso) |
---|
| 53 | + vdso = dlopen("linux-gate.so.1", |
---|
| 54 | + RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); |
---|
| 55 | + if (!vdso) { |
---|
| 56 | + printf("[SKIP]\tFailed to find vDSO. Tests are not expected to work.\n"); |
---|
| 57 | + return 0; |
---|
| 58 | + } |
---|
| 59 | + |
---|
57 | 60 | memset(&sa, 0, sizeof(sa)); |
---|
58 | 61 | sa.handler = handler_with_siginfo; |
---|
59 | 62 | sa.flags = SA_SIGINFO; |
---|
60 | 63 | sa.restorer = NULL; /* request kernel-provided restorer */ |
---|
| 64 | + |
---|
| 65 | + printf("[RUN]\tRaise a signal, SA_SIGINFO, sa.restorer == NULL\n"); |
---|
61 | 66 | |
---|
62 | 67 | if (syscall(SYS_rt_sigaction, SIGUSR1, &sa, NULL, 8) != 0) |
---|
63 | 68 | err(1, "raw rt_sigaction syscall"); |
---|
.. | .. |
---|
71 | 76 | nerrs++; |
---|
72 | 77 | } |
---|
73 | 78 | |
---|
| 79 | + printf("[RUN]\tRaise a signal, !SA_SIGINFO, sa.restorer == NULL\n"); |
---|
| 80 | + |
---|
74 | 81 | sa.flags = 0; |
---|
75 | 82 | sa.handler = handler_without_siginfo; |
---|
76 | 83 | if (syscall(SYS_sigaction, SIGUSR1, &sa, 0) != 0) |
---|