tests: check signal injection
* tests/qual_inject-signal.c: New file. * tests/qual_inject-signal.expected: Likewise. * tests/qual_inject-signal.test: New test. * tests/.gitignore: Add qual_inject-signal. * tests/Makefile.am (check_PROGRAMS): Likewise. (MISC_TESTS): Add qual_inject-signal.test. (EXTRA_DIST): Add qual_inject-signal.expected.
This commit is contained in:
parent
be73ca4bae
commit
34878f17b9
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@ -240,6 +240,7 @@ ptrace
|
||||
pwritev
|
||||
qual_fault
|
||||
qual_inject-retval
|
||||
qual_inject-signal
|
||||
qual_signal
|
||||
quotactl
|
||||
quotactl-v
|
||||
|
@ -299,6 +299,7 @@ check_PROGRAMS = \
|
||||
pwritev \
|
||||
qual_fault \
|
||||
qual_inject-retval \
|
||||
qual_inject-signal \
|
||||
qual_signal \
|
||||
quotactl \
|
||||
quotactl-v \
|
||||
@ -846,6 +847,7 @@ MISC_TESTS = \
|
||||
qual_fault-syntax.test \
|
||||
qual_fault.test \
|
||||
qual_inject-retval.test \
|
||||
qual_inject-signal.test \
|
||||
qual_inject-syntax.test \
|
||||
qual_signal.test \
|
||||
qual_syscall.test \
|
||||
@ -904,6 +906,7 @@ EXTRA_DIST = init.sh run.sh match.awk \
|
||||
ppoll.expected \
|
||||
process_vm_readv_writev.c \
|
||||
qual_fault-exit_group.expected \
|
||||
qual_inject-signal.expected \
|
||||
quotactl.h \
|
||||
scno_tampering.sh \
|
||||
setfsugid.c \
|
||||
|
57
tests/qual_inject-signal.c
Normal file
57
tests/qual_inject-signal.c
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Check that signal injection works properly.
|
||||
*
|
||||
* Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <asm/unistd.h>
|
||||
|
||||
static void
|
||||
handler(int sig)
|
||||
{
|
||||
syscall(__NR_exit_group, 0);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const struct sigaction act = { .sa_handler = handler };
|
||||
if (sigaction(SIGUSR1, &act, NULL))
|
||||
perror_msg_and_fail("sigaction");
|
||||
|
||||
sigset_t mask;
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGUSR1);
|
||||
if (sigprocmask(SIG_UNBLOCK, &mask, NULL))
|
||||
perror_msg_and_fail("sigprocmask");
|
||||
|
||||
syscall(__NR_chdir, ".");
|
||||
syscall(__NR_exit_group, 1);
|
||||
return 1;
|
||||
}
|
4
tests/qual_inject-signal.expected
Normal file
4
tests/qual_inject-signal.expected
Normal file
@ -0,0 +1,4 @@
|
||||
chdir(".") = 0
|
||||
--- SIGUSR1 {si_signo=SIGUSR1, si_code=SI_KERNEL} ---
|
||||
exit_group(0) = ?
|
||||
+++ exited with 0 +++
|
8
tests/qual_inject-signal.test
Executable file
8
tests/qual_inject-signal.test
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check signal injection.
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
run_strace -a12 -echdir,exit_group -einject=chdir:signal=USR1 \
|
||||
./qual_inject-signal
|
||||
match_diff
|
Loading…
x
Reference in New Issue
Block a user