/* * Copyright 2015, Michael Neuling, IBM Corp. * Licensed under GPLv2. * * Test the kernel's signal delievery code to ensure that we don't * trelaim twice in the kernel signal delivery code. This can happen * if we trigger a signal when in a transaction and the stack pointer * is bogus. * * This test case registers a SEGV handler, sets the stack pointer * (r1) to NULL, starts a transaction and then generates a SEGV. The * SEGV should be handled but we exit here as the stack pointer is * invalid and hance we can't sigreturn. We only need to check that * this flow doesn't crash the kernel. */ #include #include #include #include #include #include #include "utils.h" #include "tm.h" void signal_segv(int signum) { /* This should never actually run since stack is foobar */ exit(1); } int tm_signal_stack() { int pid; SKIP_IF(!have_htm()); pid = fork(); if (pid < 0) exit(1); if (pid) { /* Parent */ /* * It's likely the whole machine will crash here so if * the child ever exits, we are good. */ wait(NULL); return 0; } /* * The flow here is: * 1) register a signal handler (so signal delievery occurs) * 2) make stack pointer (r1) = NULL * 3) start transaction * 4) cause segv */ if (signal(SIGSEGV, signal_segv) == SIG_ERR) exit(1); asm volatile("li 1, 0 ;" /* stack ptr == NULL */ "1:" "tbegin.;" "beq 1b ;" /* retry forever */ "tsuspend.;" "ld 2, 0(1) ;" /* trigger segv" */ : : : "memory"); /* This should never get here due to above segv */ return 1; } int main(void) { return test_harness(tm_signal_stack, "tm_signal_stack"); } 06bdb0bac7666452d8219d7e7c477'>refslogtreecommitdiff
diff options
context:
space:
mode:
authorFeng <fgao@ikuai8.com>2017-01-20 21:40:43 +0800
committerPablo Neira Ayuso <pablo@netfilter.org>2017-02-02 14:30:19 +0100
commit10435c1192d06bdb0bac7666452d8219d7e7c477 (patch)
tree93b76419142fe17b1d162d062c663297a3e8a965 /include/net/netfilter/br_netfilter.h
parent1a28ad74ebd8f9d3c7eae0d781f72a6d30545e17 (diff)
netfilter: nf_tables: Eliminate duplicated code in nf_tables_table_enable()
If something fails in nf_tables_table_enable(), it unregisters the chains. But the rollback code is the same as nf_tables_table_disable() almostly, except there is one counter check. Now create one wrapper function to eliminate the duplicated codes. Signed-off-by: Feng <fgao@ikuai8.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/net/netfilter/br_netfilter.h')