Giter Club home page Giter Club logo

userland-execve-rust's Introduction

userland-execve

An implementation of execve() in user space.

This works by mapping the ELF executable (and interpreter, such as ld-linux.so.2) into memory, creating a stack for it (containing the auxiliary vector, arguments, and environment variables), and then jumping to the entry point with the new stack.

userland-execve-rust's People

Contributors

io12 avatar kylewlacy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

brioche-dev

userland-execve-rust's Issues

Mysterious segfault when running a program through `userland-execve`

To cut a long story short, I'm trying to use userland-execve to wrap various compiler components. Specifically, I'm following along with Linux From Scratch 12.0, using the tools from earlier chapters wrapped with userland-execve. So far, I've made it up to GCC pass 2, and this is where the story begins.

Somewhere during this build, make fails because one of the subcommands wrapped with userland-execve failed. Specifically, cc1plus (the internal GCC program for compiling C++ to assembly) ended up segfaulting. Originally, I assumed that something went wrong with an earlier build step that caused the segfault, but I narrowed it down and found that I could reliably get cc1plus-- when executed exactly the same way-- to segfault under userland-execve, but not to segfault when executed normally. Other invocations of cc1plus with userland-execve succeed, even within the same make invocation, so something goes wrong during this specific command invocation.

I spent some time creating a script that reproduces this issue in isolation, and here's what I ended up with: https://development-content.brioche.dev/files/userland-execve-segfault.tar.gz (SHA256: 9b74194f54c9a83cb601015da72390f567da2ed98b78ff9955528d737f0c1138)

This tarfile contains a repro.sh script which, when run, executes cc1plus through userland-execve, then segfaults. If you call cc1plus directly (by commenting out line 7), then the command succeeds. The only requirement for this script is that userland-execve is available on $PATH-- everything else is fully contained in the tarfile, so this should run on any x86-64 Linux system.

Also in the tarfile are two strace traces: one when calling with userland-execve and one when calling without.

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.