Comments (4)
Also if I read the Rustonmicon correctly they probably consider page faults as something that should be marked as unsafe
.
- A reference cannot outlive its referent
https://doc.rust-lang.org/nomicon/references.html
from x86_64.
4. map the page again
This would require an unsafe
operation in our current API.
from x86_64.
Maybe your right. That said I personally am not sure about the idea that page faults are not UB, but I guess it's not that big of a deal.
I just found #202 and I understand where you're coming from on this point. Would you be willing to accept a PR that adds some reasoning for this in the documentation for unmap
. Looks like I'm not the only one who thinks that way.
from x86_64.
Page faults are often handled transparently by the operating system, e.g. when swapping out pages to disk. When the CPU tries to access the referenced value, the OS can handle the page fault by reading the original page back from disk and restoring the original mapping. So the referenced value still exists and is still alive, it's just is no longer in RAM.
Another example are pages that are marked as copy-on-write during fork
. Once the CPU tries to modify a value (e.g. referenced by a &mut
) a page fault occurs. The OS typically reacts by copying the page to a new physical frame so that it can safely modified.
Of course this all depends on the correct behavior of the OS. When it maps the wrong page on a page fault, it's definitely undefined behavior. We model this in our API by making the map_to
method unsafe because that's the place where you need to ensure that no mutable aliasing etc occurs.
So I guess the question is: Is there a way to cause UB using unmap
without using any other unsafe
method such as map_to
? Is it UB to abort a user program on such a page fault?
I'm happy to discuss this further and I'm not strongly opposed to make unmap
unsafe if there is a good reason. We just try to only define methods as unsafe if absolutely needed because otherwise the whole crate would consist of unsafe
methods.
from x86_64.
Related Issues (20)
- Set minimal scoped permissions to github workflow HOT 1
- Create a Security Policy
- Mutable references in page table implementation? HOT 1
- IDT and page table code causing trouble in Confidential Computing space HOT 1
- Hash pin workflow dependencies HOT 9
- `Descriptor::tss_segment` too restrictive? HOT 2
- recursive page table with recursive index 511 is unsound HOT 7
- How can I set 2MiB page frame in my Page Directory Table? HOT 1
- How do I map to a virtualized physical address? HOT 1
- Enable OpenSSF Scorecard Action HOT 2
- [Question] Is there a reason to not support pagemaps level 5 ? HOT 2
- Trait for Entry handler function types? HOT 2
- Should we add an register abstraction? How should it work with and ?
- `VirtAddr` arithmetic may panic HOT 2
- Returning FrameAlreadyMapped error when it shouldn't HOT 10
- Should have a way to construct an `InterruptStackFrameValue`? HOT 3
- A `VirtualAddr` panic is triggered when the page table called `clean_up` HOT 3
- `Sealed::DEBUG_STR` is publicly accessible HOT 10
- PageTable: Handling of pages without the present flag set HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x86_64.