Skip to content

lind overlay for the Rust libc crate - #1378

Draft
rishabhBudhouliya wants to merge 1 commit into
mainfrom
lind-overlay
Draft

rishabhBudhouliya wants to merge 1 commit into
mainfrom
lind-overlay

Conversation

@rishabhBudhouliya

Copy link
Copy Markdown
Contributor

Summary

Rust programs built for lind use the wasm32-wasip1 target. The Rust libc crate picks its wasi module for that target, which describes wasi-libc. However, lind links the binary against lind-glibc. Struct layouts, open flags and errno values don't match causing syscall failures.

Some observed behavior when trying to run in-toto in lind-wasm:

  • metadata(): len=34359742464, is_file=false (st_size read from the wrong offset)
  • read_dir(): four entries with empty names (d_name read from the wrong offset)
  • File::create(): "os error 2" (wasi O_CREAT bit passed to a Linux open)

I was wondering why grates never have this problem and it turns out they do file I/O through raw 3i calls. The imfs grate has a workaround comment for the same bug. Would be interesting to hear more about how the grates designed around this issue.

Related issues

Testing

scripts/rust/make_lind_libc.sh copies libc 0.2.189 from the cargo registry into build/lind-libc and applies scripts/rust/lind-libc-wasi.patch. The patch changes one file, src/wasi/mod.rs: the stat and dirent layouts as measured under lind.

A crate uses it with: cargo --config 'patch.crates-io.libc.path="build/lind-libc"'

Compatibility and security impact

Checklist

  • I have read the contribution guidelines.
  • I added or updated tests where appropriate.
  • I ran the relevant tests locally and they pass.
  • I formatted the code and ran the relevant linters.
  • I updated documentation for user-visible or architectural changes.
  • I disclosed security vulnerabilities privately rather than in this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this file is a git diff result? What's the purpose of this file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants