thesis/code/leak.c

35 lines
640 B
C

#define _GNU_SOURCE
#include <sys/socket.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "pipe_utils.h"
// where does this come from?
#define OBJS_PER_SLAB 42
#define PIPE_BUFFER (OBJS_PER_SLAB * 10)
int pipes[PIPE_BUFFER][2];
int
main(void)
{
printf("main: start\n");
FILE *device = fopen("/dev/lkm", "r+");
printf("main: fopen: %p\n", device);
printf("main: draining lower page free lists: %u objects\n",
PIPE_BUFFER);
for (size_t i = 0; i < PIPE_BUFFER; i++) {
allocation_primitive(pipes[i], O_NONBLOCK);
}
fclose(device);
printf("main: done\n");
}