Skip to content

Instantly share code, notes, and snippets.

View tbodt's full-sized avatar

tbodt tbodt

View GitHub Profile
std::__1::__tree_iterator<std::__1::__value_type<std::__1::pair<WTF::MediaTime, WTF::MediaTime>, WTF::RefPtr<WebCore::MediaSample> >, std::__1::__tree_node<std::__1::__value_type<std::__1::pair<WTF::MediaTime, WTF::MediaTime>, WTF::RefPtr<WebCore::MediaSample> >, void*>*, long> std::__1::__tree<std::__1::__value_type<std::__1::pair<WTF::MediaTime, WTF::MediaTime>, WTF::RefPtr<WebCore::MediaSample> >, std::__1::__map_value_compare<std::__1::pair<WTF::MediaTime, WTF::MediaTime>, std::__1::__value_type<std::__1::pair<WTF::MediaTime, WTF::MediaTime>, WTF::RefPtr<WebCore::MediaSample> >, std::__1::less<std::__1::pair<WTF::MediaTime, WTF::MediaTime> >, true>, std::__1::allocator<std::__1::__value_type<std::__1::pair<WTF::MediaTime, WTF::MediaTime>, WTF::RefPtr<WebCore::MediaSample> > > >::__insert_unique<std::__1::pair<std::__1::pair<WTF::MediaTime, WTF::MediaTime> const, WTF::RefPtr<WebCore::MediaSample> >&>(std::__1::__tree_const_iterator<std::__1::__value_type<std::__1::pair<WTF::MediaTime, WTF::MediaTime>, WTF:
@tbodt
tbodt / buffer.c
Created August 4, 2017 02:57
circular buffer
#include <pthread.h>
#include <string.h>
#include <errno.h>
#include "buffer.h"
#define lock(thing) pthread_mutex_lock(&(thing)->lock)
#define unlock(thing) pthread_mutex_unlock(&(thing)->lock)
#define wait_for(thing, what) pthread_cond_wait(&(thing)->what, &(thing)->lock)
#define signal(thing, what) pthread_cond_broadcast(&(thing)->what)
@tbodt
tbodt / spectre.c
Created February 8, 2018 23:47 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif

Keybase proof

I hereby claim:

  • I am tbodt on github.
  • I am tbodt (https://keybase.io/tbodt) on keybase.
  • I have a public key ASDdlt9zLG4QSx4QiLFP3vguVpUCgVtSE-xtM1XCRExXhAo

To claim this, I am signing this object:

@tbodt
tbodt / patch.m
Created July 3, 2018 01:08
dylib that patches out PT_DENY_ATTACH on hopper disassembler 4.3.25 demo
static void *decrypt_start = (void *) 0x1000bafd5;
static void patch(void *addr, char value) {
*(char *) addr = value ^ (addr - decrypt_start) & 0xff;
}
static void __attribute__((constructor)) init() {
patch((void *) 0x1000bb00b, 0); // boobs
}
#include <iostream>
#include <math.h>
using namespace std;
int main() {
}
#!/bin/bash
using System;
using System.Collections.Generic;
using System.Linq;
//
// AppDelegate.m
// ptrace test
//
// Created by Theodore Dubois on 2/1/19.
// Copyright © 2019 Theodore Dubois. All rights reserved.
//
#import "AppDelegate.h"
#include <sys/mman.h>

SEQUENCE OF EVENTS

  • /file has inode 1.
  • Thread A opens /file and creates the in-memory inode 1.
  • Thread A closes its file handle and enters the code path to destroy the in-memory inode 1, but is preempted after releasing inode_lock and before calling inode_orphaned.
  • Thread B opens /file and re-creates the in-memory inode 1.
  • Thread B renames /file2, which has inode 2, to /file. This removes the last reference to inode 1 in the database.
  • Thread A wakes up and goes to finish the destruction of inode 1, which removes it from the database since it has no more references.
  • Thread B calls fstat on its open handle to inode 1. This fails because it's gone from the database.
#include <pthread.h>
#define ATOMIC 1
int flags;
void *thread(void *asdf) {
(void) asdf;
for (;;) {
#if ATOMIC
__atomic_fetch_or(&flags, 1 << 3, __ATOMIC_SEQ_CST);
@tbodt
tbodt / 75QP1iSxzMfJGmoUJ9ZJgg.png
Last active April 10, 2020 02:28
DTrace at Home
75QP1iSxzMfJGmoUJ9ZJgg.png