Skip to content

Initialize and check the stack canary at every io_tx/io_rx call#358

Merged
yogh333 merged 1 commit intodevelopfrom
stack_canary
Feb 24, 2026
Merged

Initialize and check the stack canary at every io_tx/io_rx call#358
yogh333 merged 1 commit intodevelopfrom
stack_canary

Conversation

@yogh333
Copy link
Copy Markdown
Contributor

@yogh333 yogh333 commented Feb 24, 2026

Dupplicate of #333 as PR master are now forbidden

Copilot AI review requested due to automatic review settings February 24, 2026 05:34
@yogh333 yogh333 changed the title Stack canary Initialize and check the stack canary at every io_tx/io_rx call Feb 24, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds stack overflow protection to the Ledger device SDK by implementing a canary value mechanism. The canary is placed in memory between the .bss section and the stack (as defined in the linker script), and is checked on every APDU I/O operation through the io_rx and io_tx functions.

Changes:

  • Adds a new canary module in seph.rs that initializes and checks a magic value (0xDEAD0031) stored at the app_stack_canary linker symbol
  • Integrates canary checks into both io_rx and io_tx functions, which are the primary I/O entry points used throughout the codebase
  • Uses volatile operations to prevent compiler optimization and panics if corruption is detected

Comment thread ledger_secure_sdk_sys/src/seph.rs
Comment thread ledger_secure_sdk_sys/src/seph.rs
Comment thread ledger_secure_sdk_sys/src/seph.rs
Comment thread ledger_secure_sdk_sys/src/seph.rs
@yogh333 yogh333 merged commit 6db74ab into develop Feb 24, 2026
341 of 365 checks passed
@yogh333 yogh333 deleted the stack_canary branch February 24, 2026 06:01
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