mirror_frr/lib
David Lamparter 3f11a103a6 lib: make sure SEGV handler cannot lock up
Just adding -pthread to gcc options changes libc's behaviour, e.g.
making malloc() use proper locking.  This means a SEGV inside malloc()
(e.g. because malloc bookkeeping structures have been damaged by writing
to a broken pointer) can lead to a lockup by the following chain:

- random_function()
- malloc()
--- SEGV
- core_handler()
- zlog_backtrace_sigsafe()
- backtrace()
- malloc()

This will hang forever waiting for the malloc() lock to be released.

Another failure mode is dynamic linking with lazy binding (-z lazy,
default).  Since backtrace() is seldomly used, this means the call to
backtrace() in the core handler can in fact result in the dynamic linker
trying to resolve the "backtrace" symbol, which can also deadlock.

Add several safeguards to prevent any of this from happening.

(Unfortunately, these are not theoretical issues - I found them by
running into them headfirst.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-31 16:22:33 +02:00
..
.gitignore lib: add grammar_sandbox to .gitignore 2016-12-20 06:39:37 +00:00
agentx.c build: replace some hardcoding with ./configure 2016-12-20 18:18:44 +01:00
bfd.c *: Remove non-vrf based ifindex lookup 2017-03-15 10:26:53 -04:00
bfd.h Expand #defines in command strings 2016-09-25 16:49:39 +00:00
bitfield.h Merge remote-tracking branch 'cmaster-next' into cmaster-next-releng 2016-11-19 11:58:52 +01:00
buffer.c *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs 2016-09-19 16:31:04 -04:00
buffer.h 2005-05-06 Paul Jakma <paul@dishone.st> 2005-05-06 21:25:49 +00:00
checksum.c lib: force local MIN/MAX macros 2016-09-23 12:12:17 -04:00
checksum.h lib: improve fletcher checksum validation 2012-10-25 10:15:58 -07:00
command_lex.l lib: parser: fix allocation counting 2017-01-31 15:28:19 +01:00
command_match.c Merge pull request #105 from opensourcerouting/cli_merge_step_prep 2017-01-25 07:49:21 -05:00
command_match.h lib, vtysh: Fix memory leaks, change cmd_element to const 2016-11-12 01:06:32 +00:00
command_parse.y lib: parser: remove previous deduplication code 2017-02-10 13:38:04 +01:00
command.c merge: pre-revert inapplicable changes 2017-03-10 14:18:20 +01:00
command.h lib: define BGP_EVPN_NODE 2017-02-14 13:58:57 +01:00
csv.c lib: fix remaining coverity issues 2017-02-10 15:04:06 +01:00
csv.h *: Fix up licensing to be right 2016-11-18 10:14:03 -05:00
distribute.c vtysh: parsing fixes on distribute-list 2017-03-28 15:48:07 -04:00
distribute.h lib: Make distribute.c accepts both v4 and v6. 2016-09-26 10:52:41 -04:00
event_counter.c lib: add event_counter 2016-10-18 08:39:23 -04:00
event_counter.h lib: add event_counter 2016-10-18 08:39:23 -04:00
fifo.h lib, bgpd: Remove 'struct fifo' from lib/zebra.h 2016-09-16 21:22:30 -04:00
filter.c lib: hide away logging internals 2017-03-08 00:15:40 +01:00
filter.h ldpd: introduce advanced filtering capabilities 2017-02-01 22:03:36 -02:00
getopt1.c *: make sure zebra.h is always included first 2016-06-09 10:45:22 -04:00
getopt.c *: make sure zebra.h is always included first 2016-06-09 10:45:22 -04:00
getopt.h 2005-08-10 Greg Troxel <gdt@fnord.ir.bbn.com> 2005-08-10 13:20:03 +00:00
gitversion.pl build: fix minimal mixup in gitinfo suffix 2013-04-09 17:05:08 +02:00
grammar_sandbox_main.c lib: remove remaining struct zlog * args 2017-03-08 00:15:40 +01:00
grammar_sandbox.c lib: sandbox: print vtysh daemon targets 2017-03-28 15:48:07 -04:00
graph.c lib: graph: fix vector_remove() 2017-01-26 07:05:56 +01:00
graph.h lib: parser: move allowrepeat to cmd_token 2016-12-16 20:42:01 +01:00
hash.c *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs 2016-09-19 16:31:04 -04:00
hash.h *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs 2016-09-19 16:31:04 -04:00
if_rmap.c lib: lib compiles 2016-09-23 21:34:33 +00:00
if_rmap.h 2005-05-06 Paul Jakma <paul@dishone.st> 2005-05-06 21:25:49 +00:00
if.c bgpd, lib, zebra: Rename if_update_vrf -> if_update 2017-03-15 10:55:42 -04:00
if.h bgpd, lib, zebra: Rename if_update_vrf -> if_update 2017-03-15 10:55:42 -04:00
imsg-buffer.c ldpd: adapt the code for Quagga 2016-09-23 09:31:09 -04:00
imsg.c lib: Fix clang SA warnings. 2017-01-17 18:45:23 -05:00
imsg.h ldpd: copy original sources from OpenBSD (14/09/2016) 2016-09-23 09:31:05 -04:00
jhash.c Fix most compiler warnings in default GCC build. 2016-05-26 18:57:39 +00:00
jhash.h Fix arm compilation failures of sockunion_hash issues 2015-09-08 13:26:57 -07:00
json.c lib: Allow json to work across different versions. 2017-01-17 18:46:24 -05:00
json.h lib: Allow json to work across different versions. 2017-01-17 18:46:24 -05:00
keychain.c *: apply DEFUN_NOSH for node-switch CLI commands 2017-03-28 15:48:07 -04:00
keychain.h lib: qobj: register ifaces, routemaps & keychains 2016-10-07 09:09:51 -04:00
libfrr.c lib: Fix missed code 2017-03-10 08:24:55 -05:00
libfrr.h lib: simplify protocol/log naming 2017-03-08 00:15:40 +01:00
libospf.h ospfd/ospf6d/zebra: Change interface bandwidth range and auto-cost range to 100G 2016-06-13 09:06:45 -04:00
linklist.c *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs 2016-09-19 16:31:04 -04:00
linklist.h *: remove QUAGGA_NO_DEPRECATED_INTERFACES 2017-02-27 01:14:40 +00:00
log_int.h lib: hide away logging internals 2017-03-08 00:15:40 +01:00
log.c lib: make sure SEGV handler cannot lock up 2017-03-31 16:22:33 +02:00
log.h *: fix some user-visible Quagga remnants 2017-03-08 16:15:10 +01:00
Makefile.am lib: hide away logging internals 2017-03-08 00:15:40 +01:00
md5.c *: fix signedness mix-ups 2016-06-07 08:47:49 -04:00
md5.h *: fix signedness mix-ups 2016-06-07 08:47:49 -04:00
memory_vty.c build: massively remove needless checks 2016-11-15 14:23:17 +09:00
memory_vty.h lib: clean/restore memory debugging functions 2016-09-19 16:31:08 -04:00
memory.c Merge remote-tracking branch 'origin/stable/2.0' 2017-02-07 13:20:12 -05:00
memory.h lib: replace MIT license with ISC 2016-12-01 17:18:57 +01:00
monotime.h lib: monotime.h tabs -> spaces 2017-02-27 18:50:51 +00:00
mpls.h Implement generic label manager 2017-03-20 17:10:41 +01:00
network.c lib, pimd: Modify writen to retry on certain failures 2016-12-21 20:26:10 -05:00
network.h lib: add and use set_cloexec() 2016-11-09 13:40:05 +01:00
nexthop.c Merge remote-tracking branch 'cmaster-next' into cmaster-next-releng 2016-11-28 17:35:08 +01:00
nexthop.h mpls: add support for LDP LSPs 2016-09-23 09:31:12 -04:00
ns.c *: apply DEFUN_NOSH for node-switch CLI commands 2017-03-28 15:48:07 -04:00
ns.h lib: convert namespace code to use red-black trees 2016-11-28 16:18:35 -02:00
openbsd-queue.h ldpd: copy original sources from OpenBSD (14/09/2016) 2016-09-23 09:31:05 -04:00
openbsd-tree.h ldpd: copy original sources from OpenBSD (14/09/2016) 2016-09-23 09:31:05 -04:00
pid_output.c build: massively remove needless checks 2016-11-15 14:23:17 +09:00
plist_int.h lib: Fix missing plist_int.h 2015-11-03 10:00:30 -08:00
plist.c lib: hide away logging internals 2017-03-08 00:15:40 +01:00
plist.h lib: add stream.h, vty.h, zebra.h to plist.h 2017-03-02 02:09:00 +00:00
pqueue.c *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs 2016-09-19 16:31:04 -04:00
pqueue.h lib: use heap to manage timers 2014-04-22 21:17:00 +02:00
prefix.c *: get rid of zlog(*, LOG_LEVEL, ...) 2017-03-08 00:15:39 +01:00
prefix.h lib: simplify str2mac and use struct ethaddr structure 2017-02-14 13:59:00 +01:00
privs.c lib: Don't change uid/gid if we are already the correct uid/gid 2017-01-26 00:45:05 +07:00
privs.h 2005-09-29 Paul Jakma <paul.jakma@sun.com> 2005-09-29 14:39:32 +00:00
ptm_lib.c lib: Fix possible array overrun 2017-02-01 19:51:31 -05:00
ptm_lib.h *: Fix up licensing to be right 2016-11-18 10:14:03 -05:00
qobj.c bgpd: shuffle qobj_init() 2016-12-16 20:42:01 +01:00
qobj.h lib: make qobj NULL-safe/aware 2016-12-09 17:36:25 +01:00
queue.h *: fix detection and usage of sys/cdefs.h 2014-08-18 01:50:19 +02:00
route_types.pl lib: Fix Auto generation of redistribution strings 2017-01-27 15:37:14 -05:00
route_types.txt nhrpd: implement next hop resolution protocol 2017-03-07 16:20:29 +01:00
routemap.c *: apply DEFUN_NOSH for node-switch CLI commands 2017-03-28 15:48:07 -04:00
routemap.h Support for BGP Large Communities 2017-01-18 18:38:53 -05:00
sigevent.c lib: make sure SEGV handler cannot lock up 2017-03-31 16:22:33 +02:00
sigevent.h *: use array_size() helper macro 2012-10-25 10:15:59 -07:00
skiplist.c lib: fix remaining coverity issues 2017-02-10 15:04:06 +01:00
skiplist.h lib: add skiplist 2016-09-30 13:22:35 -04:00
smux.c frr: Remove HAVE_IPV6 from code base 2017-01-13 08:05:50 -05:00
smux.h *: add missing includes 2016-06-07 08:50:09 -04:00
snmp.c snmp: fix warnings 2016-05-26 15:33:29 +00:00
sockopt.c *: add frr_init() infrastructure 2017-03-07 23:07:20 +01:00
sockopt.h *: add frr_init() infrastructure 2017-03-07 23:07:20 +01:00
sockunion.c *: get rid of zlog(*, LOG_LEVEL, ...) 2017-03-08 00:15:39 +01:00
sockunion.h frr: Remove HAVE_IPV6 from code base 2017-01-13 08:05:50 -05:00
spf_backoff.c lib: add SPF back-off implementation 2017-02-22 16:18:40 +01:00
spf_backoff.h lib: add SPF back-off implementation 2017-02-22 16:18:40 +01:00
srcdest_table.c lib: Enhance prefix dump for EVPN prefixes 2017-02-14 13:58:58 +01:00
srcdest_table.h lib: Enhance prefix dump for EVPN prefixes 2017-02-14 13:58:58 +01:00
stream.c *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs 2016-09-19 16:31:04 -04:00
stream.h Update Traffic Engineering Support for OSPFD 2016-09-03 11:05:50 -04:00
strlcat.c lib: replace strlcpy & strlcat with glibc versions 2016-11-15 17:35:36 +09:00
strlcpy.c lib: replace strlcpy & strlcat with glibc versions 2016-11-15 17:35:36 +09:00
systemd.c quagga: Fixup startup to allow consistency between sysV and systemd 2016-04-27 16:04:48 -04:00
systemd.h quagga: Fixup startup to allow consistency between sysV and systemd 2016-04-27 16:04:48 -04:00
table.c lib: add cleanup hook to route table 2017-01-30 13:54:46 +01:00
table.h lib: add cleanup hook to route table 2017-01-30 13:54:46 +01:00
thread.c *: get rid of zlog(*, LOG_LEVEL, ...) 2017-03-08 00:15:39 +01:00
thread.h lib: time: remove leftover declarations 2017-03-08 00:15:40 +01:00
vector.c lib: add vector_unset_value() 2017-01-31 15:28:19 +01:00
vector.h lib: add vector_unset_value() 2017-01-31 15:28:19 +01:00
version.h.in build: replace some hardcoding with ./configure 2016-12-20 18:18:44 +01:00
vrf.c *: apply DEFUN_NOSH for node-switch CLI commands 2017-03-28 15:48:07 -04:00
vrf.h lib: Add VRF_ALL define 2017-01-23 22:34:49 -05:00
vty.c *: apply DEFUN_NOSH for node-switch CLI commands 2017-03-28 15:48:07 -04:00
vty.h Lowercase frr.conf 2017-03-09 09:45:00 -05:00
wheel.c lib: Add Timer Wheel functionality 2017-01-17 18:40:25 -05:00
wheel.h lib: Add some documentation to wheel.h 2017-01-18 19:08:04 -05:00
workqueue.c *: make DEFUN installations file-local 2016-12-01 17:25:56 +01:00
workqueue.h *: make DEFUN installations file-local 2016-12-01 17:25:56 +01:00
zassert.h Add missing GPL headers, and copyright claims that certainly apply. 2016-05-26 01:06:59 +00:00
zclient.c Merge pull request #285 from bingen/label_manager_3 2017-03-21 11:40:20 -04:00
zclient.h Implement generic label manager 2017-03-20 17:10:41 +01:00
zebra.h lib: replace AFI_ETHER reference with AFI_L2VPN 2017-02-14 13:59:00 +01:00