Skip to content

πŸ›‘οΈ Sentinel: Fix SIGBUS on input/output path collision#3

Closed
kassoulet wants to merge 1 commit intomainfrom
sentinel/fix-sigbus-mmap-truncation-15379727575619323244
Closed

πŸ›‘οΈ Sentinel: Fix SIGBUS on input/output path collision#3
kassoulet wants to merge 1 commit intomainfrom
sentinel/fix-sigbus-mmap-truncation-15379727575619323244

Conversation

@kassoulet
Copy link
Copy Markdown
Owner

This PR fixes a critical vulnerability where the application would crash with a SIGBUS signal if the user accidentally specified the same file for both input and output. This happened because the input file is memory-mapped for high-performance processing, and opening it again for writing (with truncation) invalidated the memory mapping.

The fix involves:

  1. Moving the output path determination logic to the beginning of the main function.
  2. Using std::fs::canonicalize to compare the absolute paths of the input and output files.
  3. Returning a clear error message instead of proceeding if the paths are the same.

This change is under 50 lines and follows the security requirements for the project.


PR created automatically by Jules for task 15379727575619323244 started by @kassoulet

-   🚨 Severity: CRITICAL
-   πŸ’‘ Vulnerability: A SIGBUS crash occurs when the output file path is the same as the input file path.
-   🎯 Impact: Opening the output file for writing truncates the input file while it is still memory-mapped, causing the application to crash immediately with a Bus Error (SIGBUS).
-   πŸ”§ Fix: Use \`std::fs::canonicalize\` to verify that input and output file paths are distinct before opening the output file.
-   βœ… Verification: Verified with a reproduction script that formerly crashed and now reports a proper error message. All existing tests pass.

Co-authored-by: kassoulet <1905+kassoulet@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@kassoulet kassoulet closed this Jan 29, 2026
@kassoulet kassoulet added the duplicate This issue or pull request already exists label Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant