Coder Social home page Coder Social logo

zeromaps's Introduction

A "living" Linux process with no memory

tl;dr

  • thread1 goes into uninterruptible sleep
  • thread2 unmaps everything and segfaults
  • segv can't kill the process because of thread1's D state
  • /proc/pid/maps is now empty
  • ???
  • PROFIT!!!

asciicast

Implementation details

This code gets a list of all memory maps from /proc/self/maps, then creates a new executable map where it jits some code that calls munmap() on each of the maps it just got, and finally on the map it's on. This is just a quick example with no portability in mind, so the source code contains the actual bytes that would be emitted by a x64 compiler. After unmapping the final map, where the jit code lies, there's no new instruction to execute and a segfault is raised.

This segfault can't kill the entire process if one thread is stuck in uninterruptible sleep. To reliably send a thread in such state, we create a simple FUSE filesystem in python, in which doing anything on a particular file will block until a key is pressed.

This code also does its own "linking" to make sure that the list of maps doesn't get unmapped too early.

Requirements

  • a c compiler
  • python2 + fuse
  • x64
  • a modern Linux with no vsyscall page (this page is too high up and munmap would return EINVAL)

Why

I don't know. I thought it was funny.

zeromaps's People

Contributors

izabera avatar

Watchers

James Cloos avatar  avatar

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.