microsoft / microsoft/litebox

flattened model for syscall parsing

Open
#537 1 comment 0 reactions 1 assignee View on GitHub

@jaybosamiya-ms is already working on this.

Since Dec 8, 2025.

enhancement
Dominant language
Rust
Stars
2.7k
Forks
144
Avg merge
12h 21m
Merged PRs (30d)
146

Description

I have been meaning to bring this up...

I think we should consider changing the way we parse syscalls a bit... right now, we have three layers of syscall handling: the parsing code here which constructs the enum, the dispatch code which matches on the enum, and then the individual sys_* methods.

In some cases, we spread the syscall parsing and handling across all three places--we check some parameters here in the parsing code and return various errnos, we check some more parameters in the dispatch code (or even copy user parameters to kernel memory), and then we do yet more validation in the syscall itself.

It seems to me that we should flatten all of this and do all the validation and arg parsing in the sys_* methods. This is slightly less powerful, in that you can't reuse the parsing code with multiple syscall implementations. But I don't think that's a realistic goal, anyway, because the parsing logic is very specific to the individual implementation.

In that world, the separate enum goes away, and the dispatch code is just a big table of syscall number to sys_* fn--some Rust trickery can handle converting the parameter types. But getting there is a big effort, and we need to agree to it first.

If this seems vaguely right to everyone, then I suggest that in the meantime, we stop adding complicated code to the parsing and dispatch layers. In this case, just have socketcall parse into Socketcall { call: i32, args: ConstPtr<usize> }, and have the dispatch layer call sys_socketcall(call: i32, args: ConstPtr<usize>) -> _. Then do this complicated parsing there.

Originally posted by @jstarks in https://github.com/microsoft/litebox/pull/535#discussion_r2586725163

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.