vlang / vinix

Vinix is an effort to write a modern, fast, and useful operating system in the V programming language
https://vlang.io
GNU General Public License v2.0
1.89k stars 120 forks source link

Panic when executing specially-crafted file #129

Open hyperfocusaurus opened 8 months ago

hyperfocusaurus commented 8 months ago

If you create a file called /bin/loop with the following contents:

#!/bin/loop

The VINIX kernel will infinitely recurse in the userland.start_program function, until it eventually runs out of stack space and panics.

The way Linux deals with this case is by keeping track of the recursion depth, and setting errno = ELOOP and returning if the arbitrary max depth is reached (I believe the depth is 4 on linux, but don't quote me on that).