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

Improve pointer documentation of the applet API #717

Merged
merged 4 commits into from
Jan 7, 2025
Merged

Conversation

ia0
Copy link
Member

@ia0 ia0 commented Jan 3, 2025

This also fixes some soundness issues in the Rust prelude.

@ia0 ia0 added lang:rust Modifies the Rust prelude for:security Improves firmware or project security labels Jan 3, 2025
@ia0 ia0 requested a review from ia0-review January 3, 2025 14:31
Copy link
Collaborator

@ia0-review ia0-review left a comment

Choose a reason for hiding this comment

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

Seems like there's a bug when running the store test applet on the host runner.

crates/prelude/src/platform/update.rs Outdated Show resolved Hide resolved
crates/prelude/src/serial.rs Outdated Show resolved Hide resolved
crates/prelude/src/serial.rs Outdated Show resolved Hide resolved
@ia0
Copy link
Member Author

ia0 commented Jan 6, 2025

The applet is trapping because the allocator now returns a null pointer on zero size instead of allocating (which was wasteful but correct). Let's specify somewhere (api-desc documentation?) the common safety invariants regarding pointer-related functions (exported alloc and all imported functions mentioning pointers including function pointers).

@ia0 ia0 changed the title Add safety comments in the prelude Improve pointer documentation of the applet API Jan 6, 2025
@ia0 ia0 requested a review from ia0-review January 6, 2025 15:19
ia0-review
ia0-review previously approved these changes Jan 6, 2025
@ia0
Copy link
Member Author

ia0 commented Jan 6, 2025

@not-an-aardvark Feel free to review if you got time (you can filter out the Cargo.lock files which are just noise, as well as the Cargo.toml and CHANGELOG.md files). The main file is crates/api-desc/src/api.md which describes the general invariant.

@ia0 ia0 merged commit f965099 into google:main Jan 7, 2025
21 checks passed
@ia0 ia0 deleted the unsafe branch January 7, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for:security Improves firmware or project security lang:rust Modifies the Rust prelude
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants