]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
kernel: hardening and cleanup fixes (Round 4)
authorTulio A M Mendes <[email protected]>
Mon, 25 May 2026 14:34:19 +0000 (11:34 -0300)
committerTulio A M Mendes <[email protected]>
Wed, 3 Jun 2026 04:02:35 +0000 (01:02 -0300)
commitbeae9b7ed06d3f18846ce0ab07294c98fe9cd70c
treeadc9efae79dac401bf88b231d2cae4e7f38a7f1a
parent4d1926cfa88de50b0301a70c3890b743dd86ccb0
kernel: hardening and cleanup fixes (Round 4)

- Rename socket_syscall_dispatch to extended_syscall_dispatch (handles
  MQ, SEM, DLOPEN, EPOLL, INOTIFY, AIO, MOUNT, etc., not just sockets)
- Implement POSIX saved set-user-ID / set-group-ID:
  - Add suid/sgid fields to struct process (at end to preserve offsets)
  - setuid(2): when root, sets uid/euid/suid; non-root can set euid
    to uid or suid (POSIX spec)
  - setgid(2): same pattern for gid/egid/sgid
  - seteuid(2): saves old euid to suid, allows switch to suid
  - setegid(2): saves old egid to sgid, allows switch to sgid
  - suid/sgid inherited on fork and clone
- Add SYSCALL_REBOOT (142): root-only, cmd 0=halt, 1=reboot,
  2=poweroff. Uses hal_system_reboot() and new hal_system_shutdown()
  (QEMU ACPI port 0x604 for poweroff)

Fixes: L04 (saved set-user-ID), L05 (reboot syscall), L06 (naming)
include/hal/system.h
include/process.h
include/syscall.h
src/hal/x86/system.c
src/kernel/scheduler.c
src/kernel/syscall.c
user/ulibc/include/syscall.h