bmcweb: Log throw-site stack on std::terminate

Uncaught exceptions in gbmcweb reach std::terminate only after asio's
io_context and the sdbusplus posted-rethrow loop have already unwound the
stack, so the default terminate handler prints a backtrace that no longer
contains the original throw site. This makes fleet crashes from stray
exceptions very hard to triage.

Interpose __cxa_throw (the folly exception_tracer technique, reduced to a
single self-contained translation unit) to record the throw-site stack of
every exception, keyed by the exception object address, and install a
std::terminate handler that looks the record up via the in-flight
exception_ptr and logs it. The terminate path performs no allocation,
takes no locks and cannot re-enter, since it may run under suspected heap
corruption.

For the interposer to record throws from libstdc++ and other shared
objects -- not just the executable's own code -- it must win dynamic
symbol resolution against libstdc++'s __cxa_throw. Export it with default
visibility plus a linker --dynamic-list, and compile the tracer
translation unit directly into the executable so -Wl,--exclude-libs,ALL
cannot force it back to a local, non-interposing symbol. Without this the
interposer only captures throws whose __cxa_throw call site is compiled
into the executable, and misses standard-library and cross-library throws.

A runtime kill switch (--exception_stack_tracer=false) disables recording
and keeps the default terminate handler.

The tracer depends on glibc backtrace(), libgcc unwinding and the Itanium
__cxa_throw ABI, so it is built only in the meson/yocto (gcc) image.
Every reference to it from webserver_main_setup is guarded by
BMCWEB_ENABLE_EXCEPTION_STACK_TRACER, which is defined only by meson, so
the google3/blaze build carries no dependency on the tracer. The tracer
source, header and test are GoB-only.

Tested:
- Built gbmcweb and ran the unit tests inside the gbmcweb Gerrit
  presubmit gcc image (openbmc-ubuntu-unit-test) with the presubmit meson
  flags; exception_stack_tracer_test passes 4/4.
- Verified the guarded references compile out when
  BMCWEB_ENABLE_EXCEPTION_STACK_TRACER is undefined.
- On an emulated BMC image in Mimik (QEMU), using an out-of-tree
  debug-only endpoint that throws from a separate shared library through
  asio's inline executor (catch + async rethrow), confirmed the terminate
  handler logged the throw-site stack and that it symbolized across both
  modules. Before exporting the interposer the same cross-module throw was
  not recorded; after, it is. Verified with readelf that __cxa_throw is
  GLOBAL DEFAULT in the executable's dynamic symbol table.

Google-Bug-Id: 553672958
Signed-off-by: Yuli Fiterman <fiterman@google.com>
Change-Id: Ib461c25ffd44188707b628fad9d85f08ef516549
8 files changed
tree: 56cd4133b84a6d1c4fada5e19737a7069b8a6fed
  1. .github/
  2. config/
  3. devpath_plugin/
  4. g3/
  5. http/
  6. include/
  7. install/
  8. plugins/
  9. redfish-core/
  10. redfish_authorization/
  11. scripts/
  12. src/
  13. static/
  14. subprojects/
  15. test/
  16. tlbmc/
  17. .clang-format
  18. .clang-tidy
  19. .clang-tidy-ignore
  20. .dockerignore
  21. .gitignore
  22. .markdownlint.yaml
  23. .openbmc-enforce-gitlint
  24. .openbmc-no-clang
  25. .openbmc-no-sanitize
  26. .prettierignore
  27. .shellcheck
  28. AGGREGATION.md
  29. CLIENTS.md
  30. COMMON_ERRORS.md
  31. copy.bara.sky
  32. DBUS_USAGE.md
  33. DEVELOPING.md
  34. exception_stack_tracer.dynlist
  35. gcovr.cfg
  36. HEADERS.md
  37. LICENSE
  38. meson.build
  39. meson_options.txt
  40. OEM_SCHEMAS.md
  41. OWNERS
  42. PLUGINS.md
  43. README.md
  44. README_GOOGLE.md
  45. Redfish.md
  46. run-ci
  47. setup.cfg
  48. TESTING.md
  49. UNIT_TESTING.md
README.md

OpenBMC webserver

This project is Google's version of BMCWeb.

See Readme Google for Google added features. The following is the original README of OpenBMC/BMCWeb.

==============================================================================

This component attempts to be a “do everything” embedded webserver for OpenBMC.

Features

The webserver implements a few distinct interfaces:

  • DBus event websocket. Allows registering on changes to specific dbus paths, properties, and will send an event from the websocket if those filters match.
  • OpenBMC DBus REST api. Allows direct, low interference, high fidelity access to dbus and the objects it represents.
  • Serial: A serial websocket for interacting with the host serial console through websockets.
  • Redfish: A protocol compliant, DBus to Redfish translator.
  • KVM: A websocket based implementation of the RFB (VNC) frame buffer protocol intended to mate to webui-vue to provide a complete KVM implementation.

Protocols

bmcweb at a protocol level supports http and https. TLS is supported through OpenSSL.

AuthX

Authentication

Bmcweb supports multiple authentication protocols:

  • Basic authentication per RFC7617
  • Cookie based authentication for authenticating against webui-vue
  • Mutual TLS authentication based on OpenSSL
  • Session authentication through webui-vue
  • XToken based authentication conformant to Redfish DSP0266

Each of these types of authentication is able to be enabled or disabled both via runtime policy changes (through the relevant Redfish APIs) or via configure time options. All authentication mechanisms supporting username/password are routed to libpam, to allow for customization in authentication implementations.

Authorization

All authorization in bmcweb is determined at routing time, and per route, and conform to the Redfish PrivilegeRegistry.

*Note: Non-Redfish functions are mapped to the closest equivalent Redfish privilege level.

Configuration

bmcweb is configured per the meson build files. Available options are documented in meson_options.txt

Compile bmcweb with default options

meson builddir
ninja -C builddir

If any of the dependencies are not found on the host system during configuration, meson will automatically download them via its wrap dependencies mentioned in bmcweb/subprojects.

Use of persistent data

bmcweb relies on some on-system data for storage of persistent data that is internal to the process. Details on the exact data stored and when it is read/written can seen from the persistent_data namespace.

TLS certificate generation

When SSL support is enabled and a usable certificate is not found, bmcweb will generate a self-signed a certificate before launching the server. Please see the bmcweb source code for details on the parameters this certificate is built with.

Redfish Aggregation

bmcweb is capable of aggregating resources from satellite BMCs. Refer to AGGREGATION.md for more information on how to enable and use this feature.