Skip to content

Instantly share code, notes, and snippets.

View heatd's full-sized avatar

Pedro Falcato heatd

  • Lisbon, Portugal
  • 05:01 (UTC)
View GitHub Profile
From 952cb02a0bbe95647507047776a11e3c3cc80d9b Mon Sep 17 00:00:00 2001
From: Pedro Falcato <pedro.falcato@gmail.com>
Date: Sat, 5 Nov 2022 04:57:39 +0000
Subject: [PATCH] fs/binfmt_elf: Fix memsz > filesz handling
<TODO>
Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
---
fs/binfmt_elf.c | 170 ++++++++++++++++--------------------------------
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
int main()
{
int fd = open("test", O_RDWR | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
return 1;

EXT4 driver for Tianocore (GSoC 2021)

As part of GSoC 2021, I took on the task of writing an EXT4 driver for Tianocore, the main open-source UEFI implementation. This resulted in the addition of the Ext4Pkg package, and Ext4Dxe (which is the driver itself) to edk2-platforms, in Features/. In the process, I learned the ropes at Tianocore and edk2/edk2-platforms, which got me working on an open-source project I had never worked on before. Naturally, I had to adjust to the coding style and the community, which were both quite different from any project I had collaborated on before.

Ext4Dxe

The driver, Ext4Dxe, is a read-only UEFI DXE driver that consumes the Disk IO and Block IO protocols and produces the

CSGO-YS5Yd-h6rsE-UJOEe-ZaEcX-StPcF
uintptr_t aligned_address = phdrs[i].p_vaddr & 0xFFFFFFFFFFFFF000;
size_t total_size = phdrs[i].p_memsz + (phdrs[i].p_vaddr - aligned_address);
size_t pages = total_size / PAGE_SIZE;
if(total_size % PAGE_SIZE)
pages++;
/* Sanitize the address first */
if(vm_sanitize_address((void*) aligned_address, pages) < 0)
return false;
int prot = (VM_USER) |
uintptr_t get_starting_kernel_area(int bits)
{
uintptr_t start = 0xffffffffffffffffUL;
return start << bits;
}
static struct irq_work *queue = NULL;
int irq_schedule_work(void (*callback)(void *, size_t), size_t payload_size, void *payload)
{
struct irq_work *q = queue;
while(q->callback)
{
q = (struct irq_work *) (char*) &q->payload + q->payload_size;
}
uintptr_t remaining_size = ((uintptr_t) queue + IRQ_WORK_QUEUE_SIZE) - (uintptr_t) q;
if(sizeof(struct irq_work) + payload_size > remaining_size)
@heatd
heatd / map.c
Created December 1, 2016 17:19
void paging_map_all_phys(size_t bytes)
{
uintptr_t virt = 0xffffea0000000000;
decomposed_addr_t decAddr;
memcpy(&decAddr, &virt, sizeof(decomposed_addr_t));
uint64_t* entry = &current_pml4->entries[decAddr.pml4];
PML3* pml3 = NULL;
/* If its present, use that pml3 */
if(*entry & 1) {
pml3 = (PML3*)(*entry & 0x0FFFFFFFFFFFF000);