Giter Site home page Giter Site logo

Comments (7)

NineKa avatar NineKa commented on August 14, 2024

Hello. If I am not mistaken, these are the functions that should be implemented by the embedded system. In the compiled WebAssembly module, these are declared as import functions. For detailed documentation, check this, https://github.com/WebAssembly/WASI/blob/master/design/WASI-core.md .

from wasi-libc.

Kevin0626 avatar Kevin0626 commented on August 14, 2024

Thanks! @NineKa

In the repo readme, it introduced this repo provides a wasi reference implementation. so I assume it should be somewhere in the bottom half.

from wasi-libc.

sunfishcode avatar sunfishcode commented on August 14, 2024

Yes; the "bottom half" here refers to the bottom half of "libc", which is functions like pread which are wrappers around calls to system calls like __wasi_fd_pread. These system calls aren't implemented in libc -- they need to be provided by the embedder. For example, Wasmtime's implementation for Unix-type platforms is here.

from wasi-libc.

Kevin0626 avatar Kevin0626 commented on August 14, 2024

@sunfishcode Thanks, Dan!

I think I got some understanding about this repo structure now. The bottom half are mostly the added component on the musl with additional permission check and re-routing the syscalls to the WASI APIs.

If my understanding is right, I have another question - the bottom half seems to be built as part of WASM application binary. For the security reason, should we put the permission into the runtime implementation rather than being part of application?

from wasi-libc.

tschneidereit avatar tschneidereit commented on August 14, 2024

You're right, any required security checks need to happen in the runtime—and they do. For example the implementation of __wasi_fd_pread in Wasmtime that @sunfishcode mentions contains checks that ensure that the requested operation is allowed. If you look at the implementation of pread here, it doesn't perform any security checks itself; it just calls __wasi_fd_pread and then just tries to provide some more specific information if the check failed and otherwise just returns an error.

from wasi-libc.

Kevin0626 avatar Kevin0626 commented on August 14, 2024

@tschneidereit Thank you for your further explanation! I was trying to understand what is the boundary between the top half and bottom half. I just compared the current implementation of fopen and its original implementation of musl. Now I feel the bottom half is more like the replacement of some key functions from the musl source code.

It will be great if some basic introduction can be available from the readme about the boundary definition between the two half parts.

I also came up with a few other questions during exploring the source code and will raise new issues. Your input is very appreciated.

from wasi-libc.

sbc100 avatar sbc100 commented on August 14, 2024

I maintain a simple (and partial) JS implementation of the current syscall layer here: https://github.com/WebAssembly/waterfall/blob/master/src/wasi.js.

from wasi-libc.

Related Issues (20)

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.