Repository navigation
Conversation
There was a problem hiding this comment.
Superseded by the review of
d2e7e477.
This review, of dfdeafd8
💬 Approved with comments — One WARNING: the safe set_current_time_callback lets safe code break a soundness contract. There is also one test-coverage note. No production-impacting defects.
Findings: 1 warning (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #589.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] `boring/src/ssl/mod.rs:2392`: safe `set_current_time_callback` installs an arbitrary `unsafe extern "C" fn` that BoringSSL will call, so safe code can cause UB.
- **File:** boring/src/ssl/mod.rs:2392
📋 Code Quality: ⚠️ 1 warning
The safe setter takes a callback with an unchecked safety contract, and the test does not check that the mock clock was observed.
Recommendation: 📝 Minor Comments
- [WARNING]
boring/src/ssl/mod.rs:2392: safeset_current_time_callbackinstalls an arbitraryunsafe extern "C" fnthat BoringSSL will call, so safe code can cause UB. (boring/src/ssl/mod.rs:2392)
View full review
boring/src/ssl/mod.rs:2392:set_current_time_callbackis a safepub fn, but whether it is sound depends on a contract it cannot check.boring/src/ssl/test/session.rs:446: the test sets the clock but never checks that BoringSSL used it.
The rest checks out. ThreadLocalMockClock::new checks the time_t conversions, and advance_thread_local_mock_clock leaves the clock unchanged when it returns an error. raw_thread_local_mock_time always writes out_clock and never panics. use_thread_local_mock_clock(true) fails before it changes the context.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security issues found. The mock clock is something the embedding application has to turn on, and a remote peer cannot reach it. If the thread-local clock is unavailable, the callback writes a zeroed timeval.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues in this change.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: dfdeafd8
| /// | ||
| /// This is intended for testing. See [`SslCurrentTimeCallback`] for the callback's contract. | ||
| #[corresponds(SSL_CTX_set_current_time_cb)] | ||
| pub fn set_current_time_callback(&mut self, callback: SslCurrentTimeCallback) { |
There was a problem hiding this comment.
boring/src/ssl/mod.rs:2392: safe set_current_time_callback installs an arbitrary unsafe extern "C" fn that BoringSSL will call, so safe code can cause UB.
set_current_time_callback is a safe pub fn, but BoringSSL will call any unsafe extern "C" fn it is given. The callback must fully initialize out_clock and must not unwind, and nothing checks either. Safe code can pass a callback that leaves out_clock uninitialized, and BoringSSL then reads uninitialized memory. The # Safety section on the type alias does not make the setter unsafe to call. Mark the method unsafe fn with a # Safety section, or remove it from the public API and keep only the internal thread-local mock.
There was a problem hiding this comment.
✅ Approved — Both earlier findings are fixed at this commit, and no new issues were found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security issues found. The mock clock is off unless the application turns it on, and a remote peer cannot reach it.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues in this change.
📋 Code Quality: ✅ LGTM
Both earlier findings are fixed.
- Arbitrary callback: the callback is now private (
boring/src/ssl/mock_clock.rs:67).use_thread_local_mock_clockcan install only that callback or clear it. - Clock never checked: the test now asserts
session.time()against the mock time.
The checked conversions, the clock left unchanged on error, and the failure before any change to the context all work as intended.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: d2e7e477
This wraps BoringSSL’s current-time callback and adds a public thread-local mock clock with checked
Duration-based set and advance operations. The TLS 1.3 PSK-DHE session timeout test drives both handshakes on one thread with nonblocking sockets so both contexts observe the same deterministic clock.