Giter Club home page Giter Club logo

backtrace's Introduction

Test for libunwind and OpenSSL

Tries to use libunwind to unwind a stack that ends with OpenSSL's bn_mul_mont function. Causes a crash due to either some strange RSP usage or a bug in libunwind.

gdb is able to unwind the stack.

Download this repo and run

git clone https://github.com/tmhort/backtrace.git
cd backtrace
git submodule update --init
make
./test_bt
<crash>
gdb test_bt core

Alternatively, the run.sh script can be used to build everything.

Do the following to increase debug from libunwind:

export UNW_DEBUG_LEVEL=15

The libunwind submodule is a fork of https://github.com/libunwind/libunwind (as of Jun 23, 2021). It includes a small patch to output via Debug() the values that pop()/push()/pick() return/use when processing CFI CFA expressions.

To run within gdb, issue the following commands before run:

set env UNW_DEBUG_LEVEL=15
handle SIG35 nostop noprint noignore

The signal handler is necessary because the test program uses a timeer to periodically invoke unw_backtrace(). The program will eventually invoke this during OpenSSL's bn_mul_mont() which will cause a segmentation fault.

It appears that libunwind is unable to correctly calculate the values (registers) in a CFI CFA expression. In this case, the expression is:

.cfi_cfa_expression %rsp+8,%r9,8,mul,plus,deref,+8

(See https://github.com/openssl/openssl/blob/OpenSSL_1_1_1-stable/crypto/bn/asm/x86_64-mont.pl#L172)

The value of %rsp appears correct, but the value of %r9 is incorrect (way too big), and the mult operation blows this value up, such that the eventual deref causes a segmentation fault.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.