Skip to content

Instantly share code, notes, and snippets.

View paranlee's full-sized avatar
🐧
Run RISC-V run!

Paran Lee paranlee

🐧
Run RISC-V run!
View GitHub Profile
@paranlee
paranlee / mallocng.md
Created December 12, 2022 12:40 — forked from MaskRay/mallocng.md
musl mallocng

Introduced in musl v1.2.1. Design goal: "Strong hardening against memory usage errors by the caller, including detection of overflows, double-free, and use-after-free, and does not admit corruption of allocator state via these errors."

context

// Singleton: ctx
struct malloc_context {
  uint64_t secret;
#ifndef PAGESIZE
  size_t pagesize;
@paranlee
paranlee / Makefile
Created November 27, 2022 05:07 — forked from chrizchow/Makefile
Linux Minimal ioctl Network Device Example
KDIR := /home/chriz/repositories/WSL2-Linux-Kernel/
obj-m += chriz_ioctl_kernel.o
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
gcc -o chriz_ioctl_user chriz_ioctl_user.c
clean:
rm -rf *.o *.ko *.mod.* *.cmd .module* modules* Module* .*.cmd .tmp*
@paranlee
paranlee / quick_sort_mt.cpp
Created September 5, 2022 14:29 — forked from theodoregoetz/quick_sort_mt.cpp
parallel quicksort in C++11
/**
* g++ -std=c++14 quick_sort_mt.cpp -pthread && ./a.out 10000 1 1
*
*
* This works:
* ./a.out 10000 1 1
*
* This fails (unpredictably!):
* ./a.out 100000 1 1
**/
@paranlee
paranlee / gist:ad5e97d7c70a79fad702632030e46a07
Created August 25, 2022 17:05 — forked from sing1ee/gist:3087723
fibonacci by dynamic programming
# !/usr/bin/python
# -*- encoding: utf-8 -*-
import sys
dp = []
for i in range(100):
dp.append(0)
dp[0] = 0
dp[1] = 1
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/slab.h>
struct birthday {
int day;
int month;
int year;
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/tracepoint.h>
#include <asm/syscall.h>
#include <linux/sched.h>
#include <linux/fdtable.h>
#include <linux/slab.h>
#include <linux/delay.h>
@paranlee
paranlee / hide.c
Created August 17, 2022 15:27 — forked from slashdevsda/hide.c
Testing IDS with "invisible lkm"
/* tested on Linux 3.14
*
*/
#include <linux/kernel.h>
#include <linux/rculist.h>
#include <linux/moduleloader.h>
static LIST_HEAD(modules);
#define MODULE_NAME "module"
@paranlee
paranlee / Output
Created August 16, 2022 05:26 — forked from kumarabekur/Output
TEEC_RequestCancellation host and TA
root@imx6ul-iwg18m-twr-pos:~# tee-supplicant &
[1] 645
root@imx6ul-iwg18m-twr-pos:~# hello_world
RET value =0
### Thread ###
DEBUG: USER-TA:TA_CreateEntryPoint:42: has been called
FLOW: USER-TA: tee_user_mem_alloc:343: Allocate: link:[0x111b98], buf:[0x111ba8:16]
DEBUG: USER-TA:TA_OpenSessionEntryPoint:82: Hello World!
DEBUG: USER-TA:TA_OpenSessionEntryPoint:88: *****TA_OpenSessionEntryPoint***CANCEL FLAG =0
DEBUG: USER-TA:TA_OpenSessionEntryPoint:92: *******TA_OpenSessionEntryPoint******UNMASK FLAG =1
@paranlee
paranlee / create_patch.sh
Created August 16, 2022 05:23 — forked from stokito/create_patch.sh
git: create a single patch file with multiple commits
# last three commits
git format-patch -3 --stdout > multi_commit.patch
# all commits that are in your branch and not in master into a single patch file multi_commit.patch
git format-patch --signoff master --stdout > multi_commit.patch
# create patches in the folder ~/output/directory/ for all commits that are in your branch and not in master
git format-patch -o ~/output/directory/ --signoff master