r/kerneldevelopment • • Aug 06 '26

Showcase finished rewriting a lot of the BoredOS netstack

Post image
36 Upvotes

Hey reddit!

I've spent the last few weeks rewriting the network stack for my hobby OS, BoredOS.

Before i start yapping about what i changed, i'll quickly explain the netstack. BoredOS uses the lwIP stack to handle IPv4, Ipv6 (experimental), TCP, UDP and ICMP. The nice thing about LwIP is that i only have to supply hardware driver ring buffers, VFS fd's, some splinlock synchro, socket wait queues and a few syscalls.

Previously i was using a custom sysfs file interface to handle network traffic.. Which was quite shit imo. It didn't fit standard C lib calls or allow multiplexing network I/O alongside regular files. I replaced this monstrosity with a BSD socket layer and standard POSIX system calls like: socket, bind, connect, listen, accept, send, recv, select, poll, sendmsg, and recvmsg. Wiring sockets directly into the VFS fd table allows read/write and close to work on net sockets the same way they do on regular files and pipes.

BoredOS previously also had DHCP and DNS baked into the kernel with some very messy way of interacting with them, these have now all been moved into userspace with my own versions of standard fbsd netutils.

For packet handling, i moved processing out of the hardware interrupt handlers into a dedicated kernel worker thread. Processing packets directly in interrupt context was increasing interrupt latency and causing frame drops in heavy bursts, therefore hardware ISRs now just dump incoming frames into ring buffers and wake up a dedicated kernel worker thread via a wait queue. The worker thread sleeps when idle, wakes up on IRQs to drain the buffers into lwIP, and manages background timers for TCP retransmissions and ARP timeouts. For socket storage, i added kernel ring buffers backed by spinlocks and wait queues to handle blocking and non-blocking backpressure properly.

To allow my netutils and custom protocols to run without needing to ensloppify the kernel, i wrote a virtual TUN and TAP device driver. It supports layer 3 IP tunneling feeding into lwIP and Layer 2 Eth frame mode through TUNSETIFF ioctls. I also added raw socket support with AF_PACKET so userland packet sniffers can capture and inject raw ethernet frames directly. Of course meant for the skids to larp that they're hacking something xD.

For device management i added BSD style interface naming like em0 for intel gigabit cards, re0 and re1 for RealTek cards, vtnet0 for VirtIO, and tun0 for virtual devices.

With all these changes i also managed to speed up the stack by a LOT. Previously i was limited to a few Mbit/s and i am now able to push 800 Mbit/s in QEMU emulating an E1000 nic (maybe VirtIO is even faster? too lazy to test though) which basically maxes out the host machine connection.

EDIT:
Forgot to attach the gh:
https://github.com/BoredOS


r/kerneldevelopment • • Sep 30 '25

Ethereal

Thumbnail
gallery
36 Upvotes

An x86_64 operating system with a custom kernel and custom userspace. USB, networking, sound. Runs half life, GCC, binutils, etc.

https://github.com/sasdallas/Ethereal


r/kerneldevelopment • • 27d ago

Watching youtube on my hobby operating system, Ethereal

Post image
35 Upvotes

r/kerneldevelopment • • Sep 08 '26

Ethereal runs Wine!! (no AI, from-scratch kernel)

Post image
34 Upvotes

r/kerneldevelopment • • Mar 25 '26

Showcase PatchworkOS: A New Architecture, Async Direct I/O, True Capability Security, New Root Directory Concept and Userspace Components

Thumbnail
gallery
34 Upvotes

It's been quite a while since the last update, and that's because a significant portion of PatchworkOS has been rewritten. So far the core architecture of the new design is more or less finalized, with a focus on async I/O, improving the capability security model, reducing ambient authority, stealing a few micro-kernel concept to move policy into userspace (such as userspace process loading and module management) and moving userspace into a flexible component based system.

The rewrite is far from done, but below is an overview of what has been done so far. This can also be found in the README.

Philosophy

There are a few concepts that form the core of PatchworkOS, "everything is a file", asynchronous I/O, capability based security and others.

Everything is a File

The "everything is a file" philosophy means that almost all kernel resources are exposed as files, where a file is defined as an object that can be interacted with "like a file", as in it can be opened, read, written, and closed.

The file concept is distinct from a "regular file", which is a specific type of file that is stored on a disk and is what most people think of when they hear the word "file".

This can often result in unorthodox APIs that seem overcomplicated at first, but the goal is to provide a simple, consistent and most importantly composable interface for all kernel subsystems. The core argument is not that each individual API is better than its POSIX counterpart, but that they combine to form a system that is greater than the sum of its parts, allowing for behavior that was never explicitly designed for.

Plus its fun.

I/O

The I/O system is designed with several modern I/O concepts in mind. For example, all open/walk operations use openat() semantics, all I/O is vectored (uses scatter-gather lists), asynchronous and dispatched via an I/O Ring supporting timeouts and cancellation. All I/O is direct and (more or less) zero-copy.

There are two components to asynchronous I/O, the I/O Ring and I/O Request Packets.

The I/O Ring acts as the user-kernel space boundary and is made up of two circular queues mapped into userspace. The first queue is used by the userspace to submit I/O requests to the kernel. The second queue is used by the kernel to return the result of the I/O request. This system also features a virtual register system, allowing I/O Requests to store the result of their operation to a virtual register, which another I/O Request can read from into their arguments, allowing for several operations that may rely on the result of previous operations to be executed asynchronously.

The I/O Request Packet (IRP) is a self-contained structure that contains all the information needed to perform an I/O operation. When the kernel receives a submission queue entry, it will parse it and create an I/O Request Packet. The I/O Request Packet will then be sent to the appropriate vnode (file system, device, etc.) for processing, once the I/O Request is completed, the kernel will write the result of the operation into the completion queue.

If the target vnode can't complete the IRP immediately, it simply returns a "PENDING" status and the kernel continues without blocking.

For reading or writing, the I/O Request Packet uses a Scatter Gather List, which is an array of entries, each containing a page frame number, offset and length. Since the kernel identity maps all of physical memory into its address space, it can directly read from or write to any buffers provided by userspace without needing to copy them into kernel space or map them.

Built on top of this system are several layers of abstractions. For example, the iowrite() function is a simple synchronous wrapper around the I/O ring and fwrite() (provided by ANSI C) is a wrapper around iowrite() that works as expected. Many helper functions are also provided, for example iowritep() is a version of iowrite() that will use the virtual register system to perform a walk, write and drop using a single system call.

The "error" handling or status system allows for certain optimizations. For example, if a read is performed on a file such that no more data remains, the returned status will be an informational EOF status. In certain cases, this means we can skip an additional read to check for EOF, potentially saving us a system call.

The combination of this system and our "everything is a file" philosophy means that, since files are interacted with via async I/O and everything is a file, practically all operations can be asynchronous and dispatched via a I/O Ring.

Security

In PatchworkOS, there are no Access Control Lists, user IDs or similar mechanisms. Instead, PatchworkOS uses a capability security model based on file descriptors.

A process can only access files that have been passed to it via file descriptors, and since everything is a file, this applies to practically everything in the system, including devices, IPC mechanisms, etc.

The .. Operator

The .. or dotdot operator is a major security concern in a capability based system. Consider that if we pass a directory to a process that process could use .. to access the parent directory and then the parent of the parent and so on. This vulnerability would effectively make capability based security meaningless.

A tempting solution, used by other capability based systems, is to ban the use of .. entirely and instead use string parsing to normalize paths (i.e. turning a/b/.. into a). There are two primary issues with this solution, relative paths and symlinks.

As an example of a relative path, consider the path ./... The issue we encounter is that we may not know what . refers to, requiring us to track the current working directory as a string. This is not only complex but also inefficient as we would need to parse the entire path string for every traversal and also start any path traversal from the root directory instead of being able to start from any file descriptor.

We are still left with the problem of symlinks. Consider the path a/b/../c, if b is a symlink, and we proceed to normalize this path to a/c, we will end up accessing c within a not within whatever directory the symlink points to, making symlinks pointless.

There are alternative and superior solutions to this problem. However hopefully the point is clear, simply banning .. is not a good solution due to the complexity and inefficiency it introduces, and the fact that symlinks become difficult to impossible to implement. That's not even mentioning the potential for race conditions when normalizing paths.

The solution proposed by PatchworkOS comes from the realization that .. is not inherently dangerous. Instead, it is only dangerous when it can be used to grant additional capabilities.

As such we allow .. if the process can prove that it already has a capability to reach the parent directory. For example, say we have a directory structure as described below.

/
├── a
│   ├── b
│   │   └── c

Now let's say we have a process that wishes to open the b directory and that has two file descriptors, one to the c file (as in it has the capability to access c) and one to the a directory (as in it has the capability to access a, the contents of a and the contents of all subdirectories).

In this case, if we disallow the process from using .. from c to access b, we are not meaningfully preventing the process from accessing b, since it can just use the a file descriptor to access b directly. From this perspective, using .. from c is merely a more convenient way to access b, not that doing so actually grants any new capabilities to the process.

However, if the process didn't have a file descriptor to a then allowing it to use .. from c would grant additional capabilities and as such should not be allowed.

All of this does however hinge on the ability for a process to prove that it has a capability to access the parent directory. The way this is done is closely tied to how PatchworkOS handles the "root directory."

The Root Directory

In PatchworkOS there is no global root or even local root. Instead, when a process walks a path it must always specify some file descriptor to be considered the root for that specific operation.

This root file descriptor has three purposes. First, it is used to implement paths starting with /, letting paths start from the root file descriptor.

Second, it is used by a process to provide the proof discussed in the .. section. If the process tries to use .. to access the parent directory, the kernel will check if the specified root can reach that parent directory, if it can, then .. acts as expected, otherwise .. becomes a no-op to replicate expected POSIX-like behavior (e.g /../../ is equivalent to /).

Finally, the root file descriptor stores bindings. Within PatchworkOS, there is no namespace or per-process mountpoints. Instead, each file object stores a table of bindings. These bindings act as one would expect within POSIX, allowing a file to appear at a different path than its actual location within the filesystem hierarchy. When a bind is performed, that bind will only apply when walking paths from the file object whose binding table the bind was added to.

In this system one can consider binding a file to be nothing more than a convenient way to pass multiple capabilities (file descriptors) within a single file descriptor, by binding paths within its binding table. It does also allow all the expected benefits of bindings or mounts from POSIX-like systems but from a different perspective.

Standard Library

The standard library (libstd) is a superset of the ANSI C standard library, meaning that headers such as <stdio.h> and <stdlib.h> are included while POSIX headers such as <unistd.h> are not. Instead, the sys directory provides a set of PatchworkOS-specific headers such as <sys/io.h> and <sys/proc.h>.

Overall, an attempt is made to reuse and integrate our extensions cleanly without duplicating the ANSI sections of the standard library, for example the C11 <threads.h> header provides threading with <sys/proc.h> intentionally mirroring its API.

Practical Examples

Included below are some practical examples of how to use the APIs provided by PatchworkOS, and how they differ from their POSIX counterparts. These examples are not meant to be comprehensive, but rather to provide an instinct and intuition for how PatchworkOS works.

Basic File I/O

For a basic example of file I/O, let's say we wanted to open a file, write "Hello, World!" to it and then close it.

In a POSIX system, we might write:

int fd = open("/path/to/file", O_RDWR);
write(fd, "Hello, World!", 13);
close(fd);

Using the synchronous I/O wrappers in PatchworkOS, we would write:

fd_t fd;
iowalk(FDCWD, FDROOT, "/path/to/file:rw", &fd);

size_t bytesWritten;
iowrite(fd, IOBUF("Hello, World!", 13), IOCUR, &bytesWritten);
iodrop(fd);

We first open the file using iowalk(), specifying the default current working directory and root directory along with a path. Within the path we specify that we want "read and write" permissions (:rw see Path Flags and Payloads).

The term "walk" is used instead of "open" since all operations act on file descriptors and the ability to reach files relative to other files is a key part of the security model. As such, performing any operation on a file should be thought of as "walking" to it and then acting upon it, instead of merely "opening" it, after walking to a file we could walk to another file relative to it.

Note that the FDCWD and FDROOT constants are just standard file descriptors like STDIN, STDOUT and STDERR (called FDIN, FDOUT and FDERR respectively). In PatchworkOS, the current working directory and root directory are just file descriptors like any other; an agreed upon convention that allows other processes to easily inherit them as needed.

Then we write to the file using iowrite(), passing the file descriptor, a buffer containing the data to write (the iowrite() function actually expects an array of iovec_t which the IOBUF() macro creates on the stack for convenience) and the offset to write at (in this case IOCUR to write at the current offset).

Finally, we close the file using iodrop().

The term "drop" is used instead of "close" to cleanly differentiate between closing a file and closing a file descriptor. We only use the terms "open" and "close" when referring to the underlying file (file_t), while using terms such as "grab" and "drop" when referring to file descriptors (fd_t).

The iowritet(), ioreadt() and iowalkt() functions are also provided that expect an additional clock_t timeout argument. There is also an event loop based abstraction around the I/O Ring itself provided via macros with the Q suffix.

Path Flags and Payloads

A path can contain two additional optional segments, path flags and a payload. Path flags are appended after a : character and can be written in two forms, either in full form or in short form with the short form being a single letter that can be specified in groups. For example, /my/path:read:write:execute could also be written as /my/path:rwx. Note that the order of the letters and duplicates are ignored.

Beyond simple permission flags we have behavior flags such as :append, :parents, :truncate, etc. or creation flags, :create, :directory, :symlink and :hardlink. With the simple :create creating a regular file.

The payload of a path is specified after a ? character, this payload is treated as a raw string and will be passed to the underlying filesystem, allowing it to handle the payload in any way it chooses. However, typically filesystems will expect an options list in the form of key-value pairs separated by & characters.

For example, we could create a symlink by walking the path /my/path/to/source:symlink?/my/path/to/target.

Another example is concatfs which is used to concatenate the contents of several directories into a single directory. It expects the targets of the concatenation to be specified in the payload to its clone file, for example /sys/fs/concatfs/clone?targets=1,2,3,4 where 1, 2, 3 and 4 are file descriptors.

The primary intent behind the use of the flags and payload system is to allow for greater composability. With this system, any environment that can open a file, a Lua script, a shell, etc. can create any file, directory, symlink or hardlink with any permissions and flags without needing to rely on custom "PatchworkOS extensions".

One can as an exercise imagine the potential of a basic "touch" shell utility with this system.

Process Creation

Let's say we wanted to create a process, redirect its standard I/O to a set of file descriptors and then execute a program.

In a POSIX system, we might write:

int in[2];
int out[2];

pipe(in);
pipe(out);

pid_t pid = fork();
if (pid == 0)
{
    dup2(in[0], 0);
    dup2(out[1], 1);
    close(in[1]);
    close(out[0]);
    execl("/path/to/program", "program", NULL);
}

Using the synchronous I/O wrappers in PatchworkOS, we would write:

fd_t in;
fd_t out;

iowalk(FDCWD, FDROOT, "/dev/pipe/clone", &in);
iowalk(FDCWD, FDROOT, "/dev/pipe/clone", &out);

proc_fd_t fds = {{.parent = in, .child = 0}, {.parent = out, .child = 1}};
fd_t proc;
proc_create(FDCWD, FDROOT, PROC_ARGS("/path/to/program"), &fds, ARRAY_SIZE(fds), PRIO_MAX_USER, PROC_DEFAULT, &proc);

We first create two pipes by opening the special file /dev/pipe/clone twice.

Then we create a new process using the proc_create() function. This function takes in several arguments, first it takes in the root and current working directory to use when resolving paths, then it takes in a proc_args_t structure containing the command line arguments for the process which we use the PROC_ARGS() helper to construct. The second argument is an array of proc_fd_t structures allowing us to pass file descriptors to the child, where each proc_fd_t structure contains a parent file descriptor and a child file descriptor. The third argument is the size of this array which we use the ARRAY_SIZE() helper to compute. The fourth and fifth arguments are the process's priority and flags, and the sixth argument is an output pointer for a file descriptor to the child's proc directory containing files for manipulating the child.

We could optimize the pipe creation by walking to the second pipe relative to the first one. This optimization can be applied any time we wish to open the same file multiple times:

fd_t in;
fd_t out;
iowalk(FDCWD, FDROOT, "/dev/pipe/clone", &in);
iowalk(in, FDROOT, ".", &out);

It's important to note that proc_create() is not a system call; it's a wrapper around the /proc/clone file which when opened returns the root of the new processes proc directory. The kernel does nothing more than provide an empty address space that proc_create() fills using the mem file in the child's proc directory.

A process will be freed when its reference count reaches zero, as such "killing" a process is merely freeing its threads to drop their references to the process.

Environment Variables

Environment variables are typically a set of key-value pairs that provide a simple way to configure programs. This concept of environment variables maps cleanly to a directory containing files, where the name of the file is the key and its contents are the value. As such, environment variables are provided via a binding in the /env directory. This directory could either be a real directory, allowing the user to manage environment variables via the filesystem, or one could create a tmpfs instance and use that as the /env directory.

Notes/Signals

Notes are PatchworkOS's equivalent to POSIX signals which asynchronously send strings to processes.

In POSIX, if a page fault were to occur in a process running in some form of shell, we would usually receive a SIGSEGV, which is not very helpful. The core limitation is that signals are just integers, so we can't receive any additional information.

In PatchworkOS, a note is a string where the first word of the string is the note type and the rest is arbitrary data. As such, a page fault note might look like:

shell: pagefault at 0x40013b when reading present page at 0x7ffffff9af18

All that happened is that the shell printed the exit status of the process, which is also a string and in this case is set to the note that killed the process.

Mounting a Filesystem

There is no mount() system call in PatchworkOS; instead filesystems are exposed via files which are used in combination with the fdbind() function to mount filesystems.

Filesystem files are exposed by "sysfs" as directories, for example, /sys/fs/tmpfs is the filesystem directory for the tmpfs filesystem. Within these directories are "clone" files. Opening one of these clone files (for example /sys/fs/tmpfs/clone) gives us a file descriptor containing the root of a new instance of that filesystem (for more complex filesystems, for example a disk based one, additional parameters might be needed within the payload specified in iowalk() when opening the filesystem file).

Then we can use fdbind() to bind the root of the filesystem instance into our desired target:

fd_t fs;
fd_t target;
iowalk(FDCWD, FDROOT, "/sys/fs/tmpfs/clone", &fs);
iowalk(FDCWD, FDROOT, "/mnt/tmpfs", &target);
fdbind(FDROOT, target, fs);

Components

In PatchworkOS, userspace is made up of "components". These components can be anything, executable programs, libraries, headers, or just data files.

Each component is stored in a /comp/<name> directory. Within each components directory are version directories written in the form <x>.<y>.<z> (major.minor.patch).

The actual component files are stored within the version directories, usually within subdirectories like bin/, lib/, include/, etc. In addition, there is a manifest file which describes the component, its dependencies, and what capabilities it requires.

These manifests are written in a simple markup language made for PatchworkOS called S-expression CONfig (SCON), a parser is provided in libstd with the purpose of standardizing any configuration files used throughout the OS.

Included below is an example manifest file:

(component
    (description "An example component.")
    (author "Kai Norberg")
    (license MIT)
    (launch bin/example)
    (dependencies
        (libstd 1.0.0)
    )
    (capabilities
        /dev/fb
        /dev/kbd
    )
)

Launching Components

Any process can launch a component using the comp_launch() function from libstd. This function will construct a new root file descriptor for the component, with all the directories and files within the components directory and any dependencies directories, being concatenated via concatfs into a set of standard directories such as /bin, /lib, etc. and with any additional files specified via the capabilities being bound to the expected locations.

Let's take the component described above as an example. The libstd component provides a lib/libstd.so file and let's also say that libother provides a lib/libother.so file. In this case, the launched process would then find both libstd.so and libother.so in /lib. It would also be able to access see the /dev/fb/, /dev/kbd, as those were specified directly.

The comp_launch() function will automatically handle versioning via Minimum Version Selection inspired by GO, this means that the system will always choose the lowest possible version of components that satisfies all dependencies. Meaning that the version specified in a manifest might not be the version that's loaded, instead the version specified is the minimum version.

This ensures that the system is reproducible, that any updates have to be explicit ensuring that an update never breaks the system and that rollbacks are effortless (with the potential for some auto update system in the future) as the same set of dependencies will always result in the same environment, given the same manifests.

This all has one rather large limitation, in that the parent process must have all the capabilities to be passed to the child. If the child needs a capability that the parent does not have, the comp_launch() function will fail.

The Init Process

The one exception to this rule is the init process, which is special in that it is the only process "loaded" by the kernel (it is actually loaded by the bootloader and the kernel simply copies the executable into memory) since executable loading is handled in userspace. The init process is granted a FDROOT file descriptor to the root of sysfs from which it can acquire all capabilities. It uses these capabilities to load the RAM disk and setup userspace.

This means that the security model forms a tree-like structure, with init having all capabilities and all child processes having some subset of those capabilities.

Modules

PatchworkOS uses a "modular" kernel design, meaning that instead of having one big kernel binary, the kernel is split into several smaller "modules" that can be loaded and unloaded at runtime.

This is highly convenient for development, but it also has practical advantages, for example, there is no need to load a driver for a device that is not attached to the system, saving memory.

While the kernel used by PatchworkOS is distinctly (and intentionally) not a micro-kernel, drivers are loaded into the kernel, it does share some design ideas with micro-kernel designs. We try to design the kernel such that it is only responsible for the mechanism required to perform some task while userspace is responsible for policy. For example, process and module loading is handled in userspace, and, as time goes on, the usage of 9P for services will most likely further reduce the size of the kernel.

The Module Manager (modman)

The module manager is a userspace component, being no different to any other component, that is granted two capabilities the /dev/announce file and the /sys/mod directory.

The /dev/announce file allows the kernel to provide userspace with a stream of messages describing device state changes. Usually, a device being attached or detached. For example:

123456789 attach PNP0303 - _SB_.PCI0.SF8_.KBD_

Details on this format can be found the <comp/core/kernel-headers/include/kernel/drivers/announce.h> file.

When the module manager receives a massage like the one above, it will look inside the /comp/.index/devices directory, in which there are subdirectories named after each device type, in this case this would be the /comp/.index/devices/PNP0303 directory. Inside that subdirectory is a series of symlinks to components that provide kernel modules that are able to handle that device type.

Some modules may return a "DEFERRED" status, this would cause the module manager to defer the loading of that module and try again when any new device is attached.

Make your own Module

Making a module is intended to be as straightforward as possible. For the sake of demonstration, we will create a simple "Hello, World!" module.

Since kernel modules are just components, we must first create a new component. We begin by creating the comp/hello directory, in which we must create a manifest.scon file for our component, to which we write the following code:

(component
    (description "Example Hello World module.")
    (author "Your name here")
    (license MIT)
    (module mod/hello.ko)
)

This file specifies basic metadata about our component, most importantly that it provides a kernel module which the module manager can find at mod/hello.ko within our components directory.

Now we can create a hello.mk file, in the same directory as the manifest file, to which we write the following code:

COMP_NAME = hello
COMP_VERSION = 1.0.0
COMP_TYPE = module
COMP_DEVICES = BOOT_ALWAYS

include $(COMP_DIR)/Make.comp.defaults
include $(COMP_DIR)/Make.comp.rules

This .mk file describes our component to the build system, giving it its name, version, type and most importantly what devices it can handle. In this case we specify BOOT_ALWAYS which is a special device that the module manager will pretend was attached during boot, allowing modules that specify it to always be loaded.

Note that the hello.mk will cause the build system to create a symlink at /comp/.index/devices/BOOT_ALWAYS/hello pointing to our component at /comp/hello/1.0.0.

We are now able to write the actual module, we will create a src directory within comp/hello within which we create a hello.c file containing the included code:

#include <kernel/module/module.h>
#include <kernel/log/log.h>

status_t _module_procedure(const module_event_t* event)
{
    switch (event->type)
    {
    case MODULE_EVENT_LOAD:
        LOG_INFO("Hello, World!\n");
        break;
    default:
        break;
    }

    return OK;
}

The final directory structure should look something like this:

/
├── comp
│   ├── hello
│   │   ├── src
│   │   │   └── hello.c
│   │   ├── manifest.scon
│   │   └── hello.mk

We can now run the make all run command and should see a "Hello, World!" message within the kernels logs during boot.

If this didn't work, or bugs are encountered, please open an issue.

Future Plans

Now that the core of the new architecture more or less complete, the next steps will be fleshing out userspace. Starting with user accounts, some form of login manager and a new GUI.

User accounts should be rather straight forward, each account will have their own "home" and "env" directories which will be bound into the first process of that account, along with whatever other capabilities that account has been given.

The ideas for the login manager are still not finalized, but since Argon2id has been ported to PatchworkOS we will be using that for password hashing.

Finally, there have been many ideas regarding the GUI. The core limitation that we have to grapple with is that implementing GPU support is, to put it mildly, wildly outside the scope of a project like this. Which limits us to CPU or software rendering.

Using CPU rending forces us to design the "aesthetic" of our GUI around what a CPU can render most efficiently. This is the primary reason for the Windows 9x inspired GUI we had before the rewrite as it consists of simple opaque rectangular shapes which is very efficient on CPU.

So far anything more complex has been deliberately avoided to not end up in a situation where only a high-end CPU can run this OS simply because of how slow the GUI is.

However, it seems possible that, if we were to accept the cost of implementing transparency (via SIMD) which would be a not-insignificant cost but could most likely be optimized to an acceptable level. We could potentially implement a GNOME inspired design, as it also consists of relatively simple, although rounded shapes, which could be cached. Effects like shadows would be a simple partially transparent gradient that would also be cached.

Only testing will decide if such an approach will be considered acceptably performant.

Of course, as always, if you have any questions, find issues, or anything else, please leave a comment or open an issue in the GitHub.


This is a cross-post from GitHub Discussions.


r/kerneldevelopment • • Jan 12 '26

Kernel Dev as Career

34 Upvotes

Hey all! Been working on my own kernel for about a month and have been loving the process. I'm currently a backend software engineer and eventually I think I'd like to switch over to more Kernel/Low-Level systems focused engineering roles. Anyone here currently work in that area of software development? Just curious on other people's experiences and what that path is like. Thanks!


r/kerneldevelopment • • Jan 05 '26

Showcase PatchworkOS: An Overview of Security, Pseudo-Capabilities, Boxes and Namespaces (WIP)

Post image
32 Upvotes

It's been a while since the last update. The foundations for PatchworkOS's security model have been finalized which has been quite complex. We are now at a point where the core idea is done but the details and implementation is still Work In Progress and is subject to change.

Included below is an overview of where we are currently, followed by a discussion on what comes next.

Security

In PatchworkOS, there are no Access Control Lists, user IDs or similar mechanisms. Instead, PatchworkOS uses a pseudo-capability security model based on per-process mountpoint namespaces and containerization. This means that there is no global filesystem view, each process has its own view of the filesystem defined by what directories and files have been mounted or bound into its namespace.

For a basic example, say we have a process A which creates a child process B. Process A has access to a secret directory /secret that it does not want process B to access. To prevent process B from accessing the /secret directory, process A can create a new empty namespace for process B and simply not mount or bind the /secret directory into process B's namespace:

const char* argv[] = {"/base/bin/b", NULL};
pid_t child = spawn(argv, SPAWN_EMPTY_NS | SPAWN_SUSPENDED);
// Mount/bind other needed directories but not /secret
swritefile(F("/proc/%d/ctl", child), "mount ... && bind ... && start");

Alternatively, process A could mount a new empty tmpfs instance in its own namespace over the /secret directory using the ":private" flag. This prevents a child namespace from inheriting the mountpoint and process A could store whatever it wanted there:

// In process A
mount("/secret:private", "tmpfs", NULL);
fd_t secretFile = open("/secret/file:create");
...
const char* argv[] = {"/base/bin/b", NULL};
pid_t child = spawn(argv, SPAWN_COPY_NS); // Create a child namespace copying the parent's

// In process B
fd_t secretFile = open("/secret/file"); // Will fail to access the file

An interesting detail is that when process A opens the /secret directory, the dentry underlying the file descriptor is the dentry that was mounted or bound to /secret. Even if process B can see the /secret directory it would retrieve the dentry of the directory in the parent superblock, and thus see the content of that directory in the parent superblock. Namespaces prevent or enable mountpoint traversal not just directory visibility. If this means nothing to you, don't worry about it.

The namespace system allows for a composable, transparent and pseudo-capability security model. Processes can be given access to any combination of files and directories without needing hidden permission bits or similar mechanisms. Since everything is a file, this applies to practically everything in the system, including devices, IPC mechanisms, etc. For example, if you wish to prevent a process from using sockets, you could simply not mount or bind the /net directory into its namespace.

Deciding if this model is truly a capability system could be argued about. In the end, it does share the core properties of a capability model, namely that possession of a "capability" (a visible file/directory) grants access to an object (the contents or functionality of the file/directory) and that "capabilities" can be transferred between processes (using mechanisms like share() and claim() described below or through binding and mounting directories/files). However, it does lack some traditional properties of capability systems, such as a clean way to revoke access once granted. Therefore, it does not fully qualify as a pure capability system, but rather a hybrid model which shares some properties with capability systems.

It would even be possible to implement a multi-user-like system entirely in user space using namespaces by having the init process bind different directories depending on the user logging in.

Namespace Documentation

Userspace IO API Documentation

Hiding Dentries

For complex use cases, relying on just mountpoints becomes exponentially complex. As such, the Virtual File System allows a filesystem to dynamically hide directories and files using the revalidate() dentry operation.

For example, in "procfs", a process can see all the /proc/[pid]/ files of processes in its namespace and in child namespaces but for processes in parent namespaces certain files will appear to not exist in the filesystem hierarchy. The "netfs" filesystem works similarly making sure that only processes in the namespace that created a socket can see its directory.

Process Filesystem Documentation

Networking Filesystem Documentation

Share and Claim

To securely send file descriptors from one process to another, we introduce two new system calls share() and claim(). These act as a replacement for SCM_RIGHTS in UNIX domain sockets.

The share() system call generates a one-time use key which remains valid for a limited time. Since the key generated by this system call is a string it can be sent to any other process using conventional IPC.

After a process receives a shared key it can use the claim() system call to retrieve a file descriptor to the same underlying file object that was originally shared.

Included below is an example:

// In process A.
fd_t file = ...;

// Create a key that lasts for 60 seconds.
char key[KEY_128BIT];
share(&key, sizeof(key), file, CLOCKS_PER_SECOND * 60);

// In process B.

// Through IPC process B receives the key in a buffer of the max size since it cant know the size used in A.
char key[KEY_MAX] = ...; 

// Process B can now access the same file as in process A.
fd_t file = claim(&key);

Key Documentation

Userspace IO API Documentation

Boxes

In userspace, PatchworkOS provides a simple containerization mechanism to isolate processes from the rest of the system. We call such an isolated process a "box".

Note that all file paths will be specified from the perspective of the "boxd" daemons namespace, from now on called the "root" namespace as it is the ancestor of all user-space namespaces. This namespace is likely different from the namespace of any particular process. For example, the /box/ directory is hidden to the terminal box. Additionally, PatchworkOS does not follow the Filesystem Hierarchy Standard, so paths like /bin or /etc dont exist. See the Init Process Documentation for more info on the root namespace layout.

Each box is stored in a /box/[box_name] directory containing a /box/[box_name]/manifest ini-style configuration file. This file defines what files and directories the box is allowed to access. These are parsed by the boxd daemon, which is responsible for spawning and managing boxes.

Going over the entire box system is way beyond the scope of this discussion, as such we will limit the discussion to one example box and discuss how the box system is used by a user.

Documentation

The DOOM Box

As an example, PatchworkOS includes a box for running DOOM using the doomgeneric port stored at /box/doom. Its manifest file can be found here.

First, the manifest file defines the boxes metadata such as its version, author, license, etc. and information about the executable such as its path (within the boxes namespace) and its desired scheduling priority.

After that it defines the boxes "sandbox", which specifies how the box should be configured. In this case, it specifies the "empty" profile meaning that boxd will create a completely empty namespace, to the root of which it will mount a tmpfs instance and that the box is a foreground box, more on that later.

Finally, it specifies a list of default environment variables and the most important section, the "namespace" section.

The namespace section specifies a list of files and directories to bind into the boxes namespace which is what ultimately controls what the box can access. In this case, doom is given extremely limited access, only binding four directories:

  • /box/doom/bin to /app/bin, allowing it to access its own executable stored in /box/doom/bin/doom.

  • /box/doom/data to /app/data, allowing it to access any WAD files or save files stored in /box/doom/data.

  • /net/local to itself to allow it to create sockets to communicate with the Desktop Window Manager.

  • /dev/const to itself to allow it to use the /dev/const/zero file to map/allocate memory.

The doom box cannot see or access user files, system configuration files, devices or anything else outside its bound directories, it can't even create pipes or shared memory as the /dev/pipe/new and /dev/shmem/new files do not exist in its namespace.

Using Boxes

Containerization and capability models often introduce friction. In PatchworkOS, using boxes should be seamless to the point that a user should not even need to know that they are using a box.

In PatchworkOS there are only two directories for executables, /sbin for essential system binaries such as init and /base/bin for everything else.

Within the /base/bin directory is the boxspawn binary which is used via symlinks. For example, there is a symlink at /base/bin/doom pointing to boxspawn. When a user runs /base/bin/doom (or just doom if /base/bin is in the shell's PATH), the boxspawn binary will be executed, but the first argument passed to it will be /base/bin/doom due to the behavior of symlinks. The first argument is used to resolve the box name, doom in this case, and send a request to the boxd daemon to spawn the box.

All this means that from a user's perspective, running a containerized box is as simple as running any other binary, running doom from the shell will work as expected.

Foreground and Background Boxes

Boxes can be either foreground or background boxes. When a foreground box is spawned, boxd will perform additional setup such that the box will appear to be a child of the process that spawned it, setting up its stdio, process group, allowing the spawning process to retrieve its exit status, etc. This allows for a system where using containerized boxes can be indistinguishable from using a regular binary from a user perspective.

A background box on the other hand is intended for daemons and services that do not need to interact with the user. When a background box is spawned, it will run detached from the spawning process, without any stdio or similar.

Documentation

Future Plans

The immediate next step is most likely the implementation of "File Servers" via a FUSE or 9P like system. Meaning that a user-space process could implement its own file systems either for actual file systems or to create servers by implementing virtual file systems, in the same way that the kernel implements "devfs", boxd could implement "boxfs" or similar. Which would fit far more cleanly into our security model and everything is a file philosophy. Once this is implemented, significant sections of user space will need to be reimplemented.

Currently, share() and claim() are not ideal, they suffer from potential vulnerabilities that would occur if the generated key, which resides in user-space, where to leak. However, it is a very convenient way to pass file descriptors, so the idea won't be abandoned entirely, Instead the current idea is to add another parameter to specify the PID of the intended target, ensuring that even if the key leaks only the target can claim it. To avoid refactoring systems twice, this will only be added once file servers have been implemented.

There is currently a vulnerability in that file systems can be mounted by anyone, such that even if /net is not mounted into a boxes namespace of a box, it could simply mount netfs on its own and bypass the restriction. Solving this wouldn't be too difficult, it could be as simple as saying that netfs can only be mounted once, its more a question of deciding what the best way of solving it is. Hence, why the issue still exists.

It was slightly hinted at earlier, but we will be implementing multi-user support by having either the init process or boxd mount different directories depending on who is logging in. There may be some additional mechanisms in boxd itself, perhaps having a specific "user namespace" which boxes could be started within or similar. To some extent this has already been begun as the reference implementation of argon2, the PHC wining password hash, has already been ported to PatchworkOS to be used for password hashing.


This is a cross-post from GitHub Discussions.


r/kerneldevelopment • • Feb 03 '26

Question Linux kernel contribution

31 Upvotes

I have 8 years of experience as a software engineer mainly working on Linux, cpp at user space level. Professionally, I have got a very minimal chance to delve deep into Linux kernel and I am very much interested to go deep.

I have a good understanding of networking concepts so I started with netdev subsystem and started with veth.c file and started understanding the nuts and bolts of it like the structs used, how do they interact, poll function etc..

Now comes the hard part, netdev being a very matured subsystem how do I find some issues so that I can go deep, understand and contribute a patch.

Couple of options I found is syzkaller and running the self tests in kernel and finding the issue.

Request people to provide any suggestions, ideas or your experiences so that I will know how to move forward.

Thanks


r/kerneldevelopment • • Jan 14 '26

Showcase Cute TTY RTC Clock ❤️

31 Upvotes

This is the bleed kernel I’m new here on the Reddit but I’m in the discord hope to post more here

Hopefully one day match some of the cool stuff here

https://bleedkernel.com Mellon


r/kerneldevelopment • • Sep 30 '25

TacOS has a DOOM port and a userspace window manager, currently working on SMP! (Wish I'd done SMP earlier...)

Post image
31 Upvotes

r/kerneldevelopment • • Aug 17 '26

Ethereal's new taskbar and desktop UI looks amazing (no AI used + from-scratch)

Post image
30 Upvotes

r/kerneldevelopment • • Jan 09 '26

Showcase Factorio running in Astral

Thumbnail
gallery
28 Upvotes

Hello, r/kerneldevelopment! A few months ago I posted about running minecraft in Astral, which was a big milestone for my project. Ever since then, modern versions of Minecraft (up to 1.21) and even modpacks like GTNH have been run and someone even beat the ender dragon on 1.7.10! But another very cool thing has happened: Factorio Space Age has been run in Astral!

This feat was done by Qwinci, who ported his libc hzlibc to Astral. It has enough glibc compat to actually run the game! There are still some issues but he was able to load a save and, with 2 cpus, it ran close to 24fps. There is a lot of room for optimizations but this is already another great milestone for the project.

Project links:

Website: https://astral-os.org

Github: https://github.com/mathewnd/astral


r/kerneldevelopment • • Nov 14 '25

Resources + announcement

28 Upvotes

A million people have asked on both OSDev subreddits how to start or which resources to use. As per the new rule 9, questions like this will be removed. The following resources will help you get started:

OSDev wiki: https://osdev.wiki

Limine C x86-64 barebones (tutorial which will just boot you into 64 bit mode and draw a line): https://osdev.wiki/wiki/Limine_Bare_Bones

Intel Developer Manual (essential for x86 + x86_64 CPU specifics): https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html

An important skill for OSDev will be reading technical specifications. You will also need to search for relevant specifications for hardware devices and kernel designs/concepts you're working with.


r/kerneldevelopment • • Nov 02 '25

Looking for volunteers to help with CharlotteOS

28 Upvotes

Hi everyone,

As many of you know I've been working for a while now on a completely novel OS project called The Charlotte Operating System or CharlotteOS (named after my late pet cat, not the city). The OS is built around some unusual ideas compared to mainstream operating systems such as:

  • Capabilities based access control

  • A pure monolithic kernel that doesn't change at all after it's compiled

  • Low level paravirtualized device class interfaces for each supported device type; no ioctl here

  • A system namespace with typed entries and URI or similar paths that allow access over the network without mounting anything

  • Strong process isolation and flexible process environment configuration such that containers are rendered obsolete

  • Asynchronous system calls that return a poll capability that can be polled to check if it is ready, waited on for opt-in blocking until it is ready, or registration with the system to trigger an upcall when it becomes ready

The latest version of the kernel which I've written almost completely from the ground up plus or minus some libraries and existing framebuffer rendering code from the old version is in a pretty good state right now but at a point where there is a gargantuan amount of work that needs to be done to get to a proper userspace and then bring the OS as a whole to an MVP.

I am looking for anyone with skills and experience in low level Rust programming, DevOps and CI, low level software testing, and/or 64-bit ARM and RISC-V to help with making the OS multi-platform early on. We have zero funding or corporate backing but the upside is that we don't have any of the strings that come attached to them either so anyone who decides to help out will have the ability to have their voice heard and contribute to the design of the system and not just code to implement an existing design like POSIX or the millionth Linux close.

Please leave a comment or send me a DM if you have any questions.

If you want to help out please join our [Discord](https://discord.gg/vE7bCCKx4X) and/or [Matrix](https://matrix.to/#/%23charlotteos:matrix.org) server and ping mdp_cs (me).


r/kerneldevelopment • • Jul 16 '26

Multiplayer gaming on Ethereal (ClassiCube and Counter-Strike, not vibecoded or AI assisted)

Thumbnail gallery
27 Upvotes

r/kerneldevelopment • • Jul 26 '26

Links on Ethereal

Post image
25 Upvotes

This counts as a web browser in my eyes. Port hasn't been released since its a bit buggy (you can see the scrolling leaving some artifacts at the bottom bar)

Since my last post, Ethereal has also gotten support for sshd among other ports. It has also been merged into mainline mlibc.

There is no vibecoding in Ethereal. This OS is made by humans and always will be.

GitHub: https://github.com/sasdallas/Ethereal


r/kerneldevelopment • • Jan 27 '26

Showcase Big PurpleK2 Update!

Thumbnail
gallery
24 Upvotes

So I've been busy on PurpleK2 and implemented a lot of features that work nicely!

First I added a new and improved Multilevel Feedback Queue scheduler along with an ELF loader that supports static and PIE executables. Ive also added a POSIX like user system which I've put on hold to do one very important step: CoW. I really want to power through with syscalls and features so I can port something like mlibc until the end of the year. Right now in my CoW im not far along, only having basic refcounting in the PMM. Next up is the actual CoW detecting. We have also been indexed by Google (finally :3)

https://github.com/purpleK2/purpleK2

Ive also attached some screenshots of the current state of the OS!

They include a screenshot of a test program debugging to the e9 file on the DevFS.

A screenshot of the current VGA output of PurpleK2

A screenshot of all the syscalls I now have!

and a Screenshot of Pk2 on Google!


r/kerneldevelopment • • Aug 01 '26

Steam? On a hobby OS? It's more likely than you think!

Thumbnail gallery
23 Upvotes

r/kerneldevelopment • • Jul 02 '26

Showcase Stanix has a GUI now!

23 Upvotes

Stanix, my made from sratch operating system (https://github.com/tayoky/stanix) now has a GUI with a homemade widget library


r/kerneldevelopment • • Feb 26 '26

Discussion I finally got ring 3 working (and also going to rant about my SMP design)

Post image
23 Upvotes

The API is very minimal, just putchar and puts for now. Going to add more, and also move away from hardcoded raw binaries loaded at 0x10000, but otherwise, all is well.

I’m also working on SMP design. Right now, each core just runs the CLI then HLT in 16-bit mode. My design idea might be simple or overly complicated, but instead of using spinlocks and mutexes everywhere, each core communicates with the BSP whenever it needs to access shared resources. For example, if an AP needs physical memory or needs to report an incident like a kernel panic, it sends a request to the BSP.

If an AP requests a single page of physical memory, it sends an IPI to the BSP with information like the task requesting said data, the type of request, etc. Once this information is sent off to the BSP, the AP will then preempt to another task until it is given a return IPI which also contains the task ID, then when preempting back to the original task, its request is fulfilled with the needed information. Same goes for writing to the framebuffer and everything else that may be needed by a task. Things like virtual memory, and other task specific/core specific stuff are handled locally per core.

Edit: FUCK! FORGOT TO LINK TO THE SOURCE!  https://codeberg.org/KARM-Project


r/kerneldevelopment • • Feb 02 '26

CoW and fork in PurpleK2

Thumbnail
gallery
23 Upvotes

Hi all,
So since my last update I have been grinding on PurpleK2 and with some freetime because of the report card for the first semester (which I haven't gotten because school got cancelled). I now have fully working fork and CoW behavior in PurpleK2 with my simple little test app having a test for fork(). You can see the output of the test app in the first screenshot and the code for the test in the second.

I think this deserves a star (no pressure of course x3)
Here is a link the repo: https://github.com/PurpleK2/PurpleK2


r/kerneldevelopment • • Nov 03 '25

emexOS - a simple 64 bit OS

23 Upvotes

i know the bootscreen says doccr but i will change that soon
on the photo you can see all commands but there is a modules command too which doesn't work anymore
this os isn't that big but avaiable in github https://github.com/emexos/emexOS1/tree/main
maybe you want to take a look
there is a official os channel on youtube too but i don't know if its allowed to post youtube links here


r/kerneldevelopment • • Jul 11 '26

My custom x86-64 operating system runs on real hardware, no AI bullshit

Post image
22 Upvotes

r/kerneldevelopment • • May 20 '26

Showcase ZenOS: An SMP Preemptive hobby operating system.

20 Upvotes

It is an operating system I am working on since 2 - 3 years.

It has got quite a lot of features now, and I have just released it's first version today.

Hence decided to post about its existence here.

Links: GitHub

It also has a package repository (Zen can download from the internet, basic HTTP/1.0)

It is a fully-from-scratch OS, with around 100 syscalls (i know thats massive), and most of the beauty is in the userland, it has a Window manager, Harp, and around 30 applications total.

It is Multicore, multithreading, preemptive (RR), supports disk, PS/2, USB, networking, and a lot more.

It has many ports such as BusyBox, Doom, Figlet, Lua, FreeType, etc. It boots up in <1 second

Runs on mlibc, and follows the "Everything is a file" philosophy a bit. All programs are run from disk, with full disk support and FatFs.

Here's an excerpt from the README :

Kernel

  • - 64-bit x86_64 monolithic kernel

  • - Symmetric Multiprocessing (SMP)

  • - Preemptive round-robin SMP scheduler

  • - ELF64 userspace execution

  • - Dynamic loader

  • - Unix-style process model

  • - High-resolution timing via HPET

  • - ACPI-based hardware discovery and power management

Syscalls

  • 100+ POSIX-compatible / custom syscalls covering major app and C library needs.

Hardware & Drivers

  • - Framebuffer output

  • - PS/2 keyboard and mouse

  • - USB HID keyboard and mouse (xHCI)

  • - PC speaker

  • - Serial port for debugging and logging

  • - Local APIC and IOAPIC interrupt handling

  • - ATA disk driver (DMA/PIO, 28-bit LBA)

  • - PCI bus

  • - Intel e1000 Ethernet driver

  • - RTC, HPET

Networking

  • - TCP/IP stack

  • - DNS resolution

  • - **zen** — a package manager that fetches and installs packages over HTTP

  • - **wget** — downloads files over HTTP/1.0

Filesystem

  • - VFS layer with support for multiple mountpoints

  • - FAT32 via a port of [FatFs](https://elm-chan.org/fsw/ff/) by CHAN

  • - Native host-side disk image tooling (`fat_man`)

Userspace & Libc

Applications

I/O & Display


r/kerneldevelopment • • Oct 23 '25

Discussion New "Getting started" article, suggestions and ideas welcome!

Thumbnail
oshub.org
20 Upvotes

Hi!

After seeing lots of "how to get started" posts on here, and finding the official one (osdev.org) rather discouraging and outdated (not addressing AI) Ive decided to try create my own.

Trying to be a bit more "inspiring", it mostly focuses on theoretical ideas not a tutorial, code etc.

Would love any input, feedback, things to add. Been reading through the comments on these posts seeing what people really think newcomers should know.