Git Product home page Git Product logo

zeke's Introduction

Zero Kernel {#mainpage}

|'''''||
    .|'   ...'||
   ||   .|...|||  ..  .... 
 .|'    ||    || .' .|...|| 
||......|'|...||'|. || 
             .||. ||.'|...'

Zeke is a tiny Unix-like operating system implementation that has grown up from a tiny single-user CMSIS-like embedded operating system.

Sonarcloud

https://sonarcloud.io/dashboard?id=Zeke-OS_zeke

Key Features

  • Kernel
    • Fully pre-emptible kernel mode
    • Object-oriented thread scheduling system
    • One-to-one kernel threads for user processes
    • freeBSD-like sysctl interface
  • Processes
    • ASLR
    • Copy-On-Write virtual memory
    • Per process capabilities
    • Capabilities can fully replace the magic Unix super user
    • Unix-like fork and exec
    • elf32 support
    • Linux-style elf32 core dumps
  • IPC
    • Signals
    • mmap
    • pipes
    • pty
  • File Systems
    • Complete file system abstraction (VFS)
    • FAT12/16/32 support
    • Fast RAM file system
    • MBR support
    • freeBSD-like device file interface
  • Userland
    • Mostly C99 compliant libc
    • Standard user application separation by using POSIX processes
    • System call based kernel services

Port Status

HAL Status Documentation
ARM11 Stable Running Zeke on ARM
  BCM2835 Stable
  QEMU Stable Running Zeke in QEMU
MIPSel32 Incomplete Running Zeke on MIPS
  JZ4780 Incomplete

Documentation

zeke's People

Contributors

morrow3 avatar olliv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zeke's Issues

ramfs: If cwd is removed the curproc will be jailed

If the working directory of a process is removed the process is jailed to that directory
as the vnode doesn't get freed but dot and dotdot links are deleted. For some reason
chdir to / is not working either so rmdir . effectively creates a chroot-like jail.

Implement getcwd()

getcwd should try to construct the full path by going up to the root by following .. links and finding out the name of the previous directory. Full path should not contain any '.', '..', or extra '/' special characters, though those characters can appear in a directory name.

Fix order of init messages (kinit.h)

Init message of a init function is now printed before printing init messages of the dependencies of the original init function i.e. before it's actually executed giving wrong impression of booting state.

Unlink sometimes breaks the directory entry chain (dehtable)

# ls
0 40755 0:0 .
0 40755 0:0 .. 
1 40755 0:0 dev

# mkdir dir
# touch file
# ls
0 40755 0:0 .
0 40755 0:0 ..
1 40755 0:0 dev
3 100644 0:0 file
2 40750 0:0 dir

# unlink file
# ls
0 40755 0:0 .
0 40755 0:0 ..
1 40755 0:0 dev

dir is not removed after this operation but it doesn't show up in ls anymore.

Vulnerability: thread pre-emption in kernel mode may make kernel data process readable

Consider a process with two threads, both obviously have a stack that is accessible by threads of that process. Now if thread a has made a syscall but go interrupted and thread b is put on execution. What happens is that thread b could possibly read stacked kernel data from the stack of thread a.

To prevent this we'd need separated kernel mode stack for each thread. There is a little stub implemented but commented out in sched.c. Only "problem" is that it greatly complicates entry code to the scheduler. Another option might be hide/copy the data out before switching context but it doesn't sound like a feasible idea.

pty & tty

  • proper buffering
  • modes
  • controlling terminal
  • pty creation and destruction

thread_terminate() might be called twice

If Parent thread calls thread_terminate() and if execution is then transferred to the scheduler it may may call the same function again and proper timing may break the scheduler.

Periodic (kernel) event interface

It would be useful to have a (possibly statically compiled) interface to add periodically executed handlers to calculate for example loadavg or some other stats. This could be either built in timers or scheduler. Naturally these periodic tasks should be very small since scheduler is not pre-emptible.

It can be also considered if we should create a kernel thread that would handle most of these periodic tasks. Some tasks may have more strict deadlines so this kind of thread based interface may not suit for those tasks?

pid = act_maxproc breaks procfs

Let act_maxproc = 10.

If a process with pid = 10 is created it will break the procfs so that /proc/10 dir remains in the file systems but is unusable. This isn't necessarily related to procfs at all but handling of maxproc limit itself.

kernel panic after umount

# mount -t ramfs . mnt
# cd mnt
# touch file
# cd ..
# umount mnt
# ls
...
0:fs/fs_syscall.c:654: Oops, Kernel panic
0:fs/fs_syscall.c:654: vnode should be setqemu: terminating on signal 2

Random permission faults with init stack

There seems to be some strange cases where thread stack is unavailable for a short
period of time.

Init v0.0.1
4:src/proc.c:374: proc_dab_handler(): MOO
0:src/hal/arm11/arm11_mmu.c:618: SEGFAULT @ 0x00013f3c
0:src/hal/arm11/arm11_mmu.c:673: Oops, Kernel panic
0:src/hal/arm11/arm11_mmu.c:673: Can't handle data abort
pc : 0x00013f3c
fsr : 0x0000000d (Section permission fault)
far : 0x00402ef4
proc info:
pid : 0x00000001
tid : 0x00000001

fatfs doesn't detect read-only mode

If sd card or driver is in read-only mode but fatfs is mounted rw the fs driver will fail if a file is created. This doesn't however cause creat to fail but instead read and write operation after a file creation will fail.

Make umount work for inherited file systems

Move umount function pointer to superblock struct to make it callable for inherited file systems.

fs pointer in sb struct can't be altered thus we need to move umount func pointer to sb struct as
a workaround. The solution is kind of suboptimal but it requires least effort for now.

New scheduler interface

Implement a new scheduler interface that allows hooking multiple schedulers to the kernel at the same time and preferably even at run time.

current proc/thread global variables are not valid for MP

Global variables for current task can't be used on MP system:
extern volatile pid_t current_process_id;
extern volatile proc_info_t * curproc;
extern volatile threadInfo_t * current_thread;

These should be possibly replaced with arrays which specify current value for each core.

pid selection doesn't quite work

PID of a new process seems to improperly bound to maxproc quite soon after some fork()s. PID reset might be invalid for small PID sets?

getdents() doesn't handle invalid fildes

If getdents() is called with any invalid fildes it crashes the process or sometimes crashes the kernel by branching to addr 0.

Findings:

  • file that isn't a dir causes the process to hang
  • negative fildes causes branch to 0, probably non-existing function pointer 0->vnode->vnode_ops->...

mount on root fails

Mount fails to mount on top of root (/) and returns ENOENT. This seems to happen at least with devfs and fatfs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.