]> 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]>
Mon, 25 May 2026 15:38:54 +0000 (12:38 -0300)
commit127ff689be4a744bca8555a060a1291216cfa516
tree58144b31e048af7b4196e12d4688b4f2416b56ac
parentf27292ed02f4427bb2e404193832db75b2ba8a14
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