/* * vdso_restorer.c - tests vDSO-based signal restore * Copyright (c) 2015 Andrew Lutomirski * * This program is free software; you can redistribute it and/or modify * it under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * This makes sure that sa_restorer == NULL keeps working on 32-bit * configurations. Modern glibc doesn't use it under any circumstances, * so it's easy to overlook breakage. * * 64-bit userspace has never supported sa_restorer == NULL, so this is * 32-bit only. */ #define _GNU_SOURCE #include #include #include #include #include #include #include /* Open-code this -- the headers are too messy to easily use them. */ struct real_sigaction { void *handler; unsigned long flags; void *restorer; unsigned int mask[2]; }; static volatile sig_atomic_t handler_called; static void handler_with_siginfo(int sig, siginfo_t *info, void *ctx_void) { handler_called = 1; } static void handler_without_siginfo(int sig) { handler_called = 1; } int main() { int nerrs = 0; struct real_sigaction sa; memset(&sa, 0, sizeof(sa)); sa.handler = handler_with_siginfo; sa.flags = SA_SIGINFO; sa.restorer = NULL; /* request kernel-provided restorer */ if (syscall(SYS_rt_sigaction, SIGUSR1, &sa, NULL, 8) != 0) err(1, "raw rt_sigaction syscall"); raise(SIGUSR1); if (handler_called) { printf("[OK]\tSA_SIGINFO handler returned successfully\n"); } else { printf("[FAIL]\tSA_SIGINFO handler was not called\n"); nerrs++; } sa.flags = 0; sa.handler = handler_without_siginfo; if (syscall(SYS_sigaction, SIGUSR1, &sa, 0) != 0) err(1, "raw sigaction syscall"); handler_called = 0; raise(SIGUSR1); if (handler_called) { printf("[OK]\t!SA_SIGINFO handler returned successfully\n"); } else { printf("[FAIL]\t!SA_SIGINFO handler was not called\n"); nerrs++; } } xt.git/log/tools/lguest/lguest.txt'>
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2017-01-28 11:52:02 +0100
committerHelge Deller <deller@gmx.de>2017-01-28 21:54:23 +0100
commit2ad5d52d42810bed95100a3d912679d8864421ec (patch)
tree7f93e2f906b1c86f5b76c0f4c0978d41a8a29861 /tools/lguest/lguest.txt
parent83b5d1e3d3013dbf90645a5d07179d018c8243fa (diff)
parisc: Don't use BITS_PER_LONG in userspace-exported swab.h header
In swab.h the "#if BITS_PER_LONG > 32" breaks compiling userspace programs if BITS_PER_LONG is #defined by userspace with the sizeof() compiler builtin. Solve this problem by using __BITS_PER_LONG instead. Since we now #include asm/bitsperlong.h avoid further potential userspace pollution by moving the #define of SHIFT_PER_LONG to bitops.h which is not exported to userspace. This patch unbreaks compiling qemu on hppa/parisc. Signed-off-by: Helge Deller <deller@gmx.de> Cc: <stable@vger.kernel.org>
Diffstat (limited to 'tools/lguest/lguest.txt')