Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bind /tmp/ as a tmpfs for bv_decide to create temp files #38

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

bollu
Copy link
Contributor

@bollu bollu commented Sep 8, 2024

Since bv_decide uses temporary files to communicate with cadical, we bind /tmp as a read-write mount. This allows bv_decide to be successfully used in a hosted instance of lean4web: Link here.

The line of code that perform this is:

-- https://github.com/leanprover/lean4/blob/master/src/Lean/Elab/Tactic/BVDecide/Frontend/BVDecide.lean#L167-L168
Frontend/BVDecide.lean
167:    IO.FS.withTempFile fun _ lratFile => do
168:      let cfg ← BVDecide.Frontend.TacticContext.new lratFile

CC @hargoniX

@joneugster
Copy link
Collaborator

Oh I thought I've answered a while ago:

I'm not sure adding more --bind by default is a good idea. Especially since this gives any user the write-permission to write arbitrary files onto the server, which I don't know if that imposes a potential security risk.

Could we just explain this setup in the documentation (README or a MD file in docs/) or maybe implement this in a configurable way so that --bind is not used by default?

@hargoniX
Copy link

You do not need to setup this bind to allow access to /tmp. Lean's temp file mechanism does respect the TMPDIR environment variable: https://github.com/leanprover/lean4/blob/b87562719814447e77c17ff03492f7c11573f475/src/runtime/io.cpp#L847 so it is entirely possible to give it its own /tmp directory to play with.

@bollu
Copy link
Contributor Author

bollu commented Sep 19, 2024

@joneugster We switch to using --tmpfs, which creates a temporary file system for /tmp that's not visible to the host machine at all. This offers isolation from the lean server that's running inside bubblewrap to the lean host machine.

This should be setup by default, now that bv_decide and cadical are being shipped as part of Lean core.

@bollu bollu changed the title feat: bind /tmp/ in read-write mode to allow LeanSAT to create temp files feat: bind /tmp/ as a tmpfs for bv_decide to create temp files Sep 23, 2024
@joneugster joneugster merged commit 5240162 into leanprover-community:main Sep 23, 2024
2 checks passed
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.

3 participants