This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
#define likely(expr) __builtin_expect(!!(expr), 1) | |
#define unlikely(expr) __builtin_expect(!!(expr), 0) | |
#define __EXTEND_MEM (256<<10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Mempodipper | |
* by zx2c4 | |
* | |
* Linux Local Root Exploit | |
* | |
* Rather than put my write up here, per usual, this time I've put it | |
* in a rather lengthy blog post: http://blog.zx2c4.com/749 | |
* | |
* Enjoy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* word compare with SSE2 functions/instructions for faster 16 byte loads and compares. | |
* | |
* compile with: | |
* gcc -o sse_load_test sse_load.c -Wall -O2 -g -DTEST_SSE2 | |
* | |
*/ | |
#if defined(TEST_SSE2) && !defined(__SSE2__) | |
#error "no SSE2 set" | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* An example using splice syscall which avoids copying to/from user space buffers to kernel space | |
* and uses the pipe buffers allocated in kernel space as an intermediate to directly xfer from one file to another | |
* | |
* gcc -o splice splice.c -g | |
*/ | |
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <string.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Another closure example using Gopal.V's (a.k.a @t3rmin4t0r the great) | |
* excellent blogpost on closure dating all the way back to 2006! | |
* | |
* http://notmysock.org/blog/hacks/when-macros-arent-enough | |
* | |
* Resurrecting it with a useless use-case for the sake of posterity | |
* and to remind the myriads of people who say | |
* they know "C" in their resumes since they think its "Let us C" | |
* even if they work with dot NET or web tech. in their day to day life |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* A continuation example with closure. | |
* To run: | |
* | |
* gcc -o continuation continuation.c -Wall -g -lpthread | |
* ./continuation | |
* would test with creating 10 continuations each stacking 3 levels of continuations before unwinding | |
* ./continuation 20 | |
* would test with 20 continuations | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/mman.h> | |
#ifndef MAP_32BIT | |
#error "MAP_32BIT not defined" | |
#endif | |
struct scope | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Just an example to remind that its futile to free memory in the child | |
* allocated by the parent to avoid taking a break COW perf. hit. | |
* Makes sense only to free large chunk sizes in the child. Smaller chunk sizes | |
* aren't really trimmed by malloc and only end up causing perf hits with | |
* break COW pages (copy on write) when freeing in the child. | |
* A break COW is when free results in malloc lib. touching the freed chunk | |
* of memory resulting in a write protection page fault for the child that ends up | |
* unmapping the shared page table entry and then maps a writable page copy to the child. | |
* The net effect for RSS(resident set size) is the same as in the parent but |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## OUT OF OFFICE REPLY | |
#!/usr/bin/env bash | |
(gcc -x c - -o vacation && ./vacation) <<EOF | |
#include <stdio.h> | |
#include <ctype.h> | |
static char *rot(char*); | |
int main() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## OUT OF OFFICE REPLY | |
#!/usr/bin/env bash | |
(gcc -x c - -o vacation && ./vacation) <<EOF | |
#include <stdio.h> | |
#include <ctype.h> | |
static char *rot(char*); | |
int main() | |
{ |