Commit Graph

467 Commits

Author SHA1 Message Date
Matheus 5360edb9c7 pipe2: properly clean up vnode references on error
Currently, pipe2 both closes the fds and releases references to the pipe
vnode on failure. However, closing the fds already causes the vnode
references to be dropped.

Make pipe2 only release the vnode references when the respective file_t
were not closed.

Found by syzkaller fuzzing.
2026-10-09 02:11:50 -03:00
Matheus 47ce33935f mknodat: refuse to create symlinks
The current mknodat code creates symlinks when requested. Not only does
this break POSIX, it also causes a kernel crash (NULL-deref on
tmpfs_readlink).

Refuse to create symlinks with mknodat.

Found by syzkaller fuzzing.
2026-10-09 02:10:12 -03:00
Matheus b52882f3f7 syscalls: fix vnode cleanup in some *at syscalls
Some *at functions have a cleanup goto which could use an uninitialized
vnode. Fix this by defining the vnodes earlier.

Found by syzkaller fuzzing.
2026-10-09 01:41:48 -03:00
Matheus 9a9740469f kcov: move thread attach from open to start
The current kcov code attaches a kcov object to the thread which opened
it. This is not desirable, as syzkaller opens /dev/kcov in a parent
process and passes it down to the child.

Move the thread attachment from open() time to start time.
2026-10-08 18:42:25 -03:00
wnstngs bb555d0620 dpc: make dpc queues FIFO 2026-10-07 23:00:21 +03:00
wnstngs 91491d825b kernel: remove the list_t alias since it's just a typedef for node 2026-10-07 14:08:36 +03:00
wnstngs 9cffe521f3 kernel: use circular lists in various places 2026-10-07 10:32:08 +03:00
wnstngs 513faa92c7 kernel: use list.h for scheduling run queues 2026-10-07 10:24:50 +03:00
wnstngs 3894be1a15 kernel: use list.h for DPC queues 2026-10-07 10:23:18 +03:00
Matheus e4a4896b4b kcov: initial implementation
Implement a device (/dev/kcov) that exposes coverage info for the
kernel. This will be especially useful for coverage-based fuzzing (e.g.
syzkaller).

Exclude a lot of functions which would crash/otherwise interfere in the
coverage, including only processing coverage callbacks when not handling
an irq.
2026-10-06 11:51:02 -03:00
Matheus 011309d43d cpu: add irq depth counting
Add a way of checking if a cpu is in the middle of handling an irq and
how deep it is into it. This will allow for future code to conditionally
run only in/outside interrupts.
2026-10-06 11:51:01 -03:00
Matheus 0cdd03eba8 smp: fix race between cpu exposure and smp init
The SMP code exposes that a cpu woke up before it is properly
initialized in sched_ap_entry(). Fix this by initializing it first,
exposing it and then stopping the bootstrap thread.
2026-10-06 11:51:01 -03:00
Matheus 1ed159489d scheduler: only run load balance when appropriate
Prevent the load balancer from balancing when running uniprocessor
machines and when not all CPUs are online yet.

This prevents a race between ap initialization and load balancing.
2026-10-06 11:51:00 -03:00
Matheus d214326e8e print: add nouserprint argument
For some usecases, silencing syscall_print()s is ideal. A good example
of that is syzkaller, which uses logs to detect crashes and a badly
timed syscall_print() could interfere.

Add a nouserprint argument which skips printing on syscall_print().
2026-10-06 11:51:00 -03:00
Matheus e8da0eba6a statvfs: handle vnodes without a vfs 2026-10-06 11:50:58 -03:00
Matheus 68af759f20 Merge pull request #43 from wnsntgs/Kernel/Sched/NanosleepTimerFix
Fix timer cleanup in interrupted nanosleep
2026-09-23 15:09:28 -03:00
wnstngs 6780626f29 kernel: cancel interrupted nanosleep timer without remaining pointer 2026-09-23 20:48:29 +03:00
Matheus c347afc761 sched: if last cpu is idle, run on it 2026-09-19 12:50:00 -03:00
Matheus 7a533242ad scheduler: make idle cpus steal work 2026-09-16 00:22:05 -03:00
Matheus 74c0bb2450 sched: actually set cpus as idle 2026-09-15 23:19:56 -03:00
Matheus 3a421a58ad futex: style 2026-09-15 15:06:16 -03:00
Matheus 58d2e468da futex: refactor and optimize 2026-09-15 14:57:19 -03:00
Matheus cdee765643 raw sockets: make creating them a privileged operation 2026-09-14 14:03:39 -03:00
Matheus d1cc050d76 sched: fix race on thread switching 2026-09-14 13:21:47 -03:00
Matheus 3eaca91ff1 vfs: properly sync metadata 2026-09-14 10:11:31 -03:00
Matheus 66b0cb9076 sockets: expose raw sockets to userspace 2026-09-10 17:56:54 -03:00
Matheus 79752fb5e0 sock: pass protocol to sockets 2026-09-10 16:41:21 -03:00
Matheus 1b4e257793 work: initial implementation 2026-09-08 23:37:19 -03:00
Matheus d7343e7b55 scheduler: rework load balancing locking 2026-08-17 21:47:00 -03:00
Matheus 7a03f3cb0f jobctl: fix ctty stealing 2026-08-14 12:22:14 -03:00
Matheus 65358e6705 sysctl: SYS_CTL_HW_CPUS_ONLINE 2026-08-13 00:43:15 -03:00
Matheus afd9d8d3a0 rename: RENAME_NOREPLACE 2026-07-14 16:37:48 -03:00
Matheus 1512b2f3c6 mm: properly implement page locking 2026-07-08 01:37:12 -03:00
Samuel Stuart 57879f48da thread: fix release of proc refcounts on multithreaded applications 2026-07-07 17:10:21 -03:00
Matheus f46d85fe6d socket: fix close shutdown properly 2026-07-07 16:49:45 -03:00
Matheus c05163f191 socket: zero addresses on accept/recv by default 2026-07-07 11:24:44 -03:00
Matheus bf03d99211 getsockname: remove print 2026-07-07 01:14:49 -03:00
Matheus 7f8fd07f39 sock: sock_copy_addr_to_user 2026-07-05 16:16:05 -03:00
Matheus 239c267ed3 mm: rename vmm api to mm 2026-07-01 15:00:46 -03:00
Matheus d890eb5fb2 mm: vmmcache -> mm_cache 2026-07-01 12:25:18 -03:00
Matheus 6f8700e678 mm: refactor pmm -> page 2026-07-01 11:56:06 -03:00
Matheus 6a9fee0b41 proc: fix event loop while waiting 2026-06-30 18:43:56 -03:00
Matheus 7c19244208 signal: fix possible context corruption 2026-06-30 17:37:23 -03:00
Matheus 99701d2fb9 sched: fix bsp getting higher priority than target during bringup 2026-06-30 17:35:29 -03:00
Matheus 17334c8533 advlock: general fixes 2026-06-29 11:33:03 -03:00
Matheus eb798d24b4 scheduler: copy arguments in checktrampoline to prevent a race 2026-06-29 02:13:37 -03:00
Matheus 09d7f8cd1d sysctl: console_lock sysctl 2026-06-29 00:49:11 -03:00
Matheus b186bf333d proc: unlock console on exit if locked by the dying process 2026-06-29 00:46:51 -03:00
Matheus 73d60efd53 jobctl: jobctl_getsession 2026-06-29 00:45:11 -03:00
Matheus 85e12f7e7b stat: fit AT_EMPTY_PATH 2026-06-28 11:45:17 -03:00