Skip to content

Send close_notify after user_canceled even under quiet shutdown - #11264

Open
night1rider wants to merge 2 commits into
wolfSSL:masterfrom
night1rider:fenrir-10650
Open

Send close_notify after user_canceled even under quiet shutdown#11264
night1rider wants to merge 2 commits into
wolfSSL:masterfrom
night1rider:fenrir-10650

Conversation

@night1rider

Copy link
Copy Markdown
Contributor

Clear quiet shutdown across the shutdown call in wolfSSL_SendUserCanceled so the RFC 9846 paired close_notify is emitted, and cover it in test_wolfSSL_SendUserCanceled.

Clear quiet shutdown across the shutdown call in wolfSSL_SendUserCanceled so the RFC 9846 paired close_notify is emitted, and cover it in test_wolfSSL_SendUserCanceled.
@night1rider night1rider self-assigned this Aug 25, 2026

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11264

Scan targets checked: wolfssl-bugs, wolfssl-src

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

Guard the quiet-shutdown setter against a NULL ssl_s and assert quietShutdown is restored after SendUserCanceled, per PR wolfSSL#11264 review.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11264

Scan targets checked: wolfssl-bugs, wolfssl-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/ssl_api_rw.c
int quietShutdown = ssl->options.quietShutdown;
ssl->options.quietShutdown = 0;
ret = wolfSSL_shutdown(ssl);
ssl->options.quietShutdown = quietShutdown;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Restored quiet shutdown blocks the retry that flushes a buffered close_notify · Logic errors

When wolfSSL_shutdown leaves the close_notify in the output buffer (SendAlert returns WANT_WRITE, ssl_api_rw.c:921), restoring quietShutdown makes the caller's retry short-circuit at ssl_api_rw.c:1041 and never reach wolfssl_shutdown_flush_alert, so the alert is never sent yet shutdown reports success. Adjacent to known finding #10650, on the retry path.

Related known finding #10650 (similar but distinct): Both involve wolfSSL_SendUserCanceled and quietShutdown preventing the required close_notify, but #10650 is the initial shutdown short-circuit before any send attempt. This finding concerns a later WANT_WRITE retry after close_notify was buffered and quietShutdown was restored; it requires preserving the override through alert flushing, a distinct operation and patch.

Fix: Skip the restore while the alert is still unflushed (e.g. when ssl->error == WANT_WRITE), restoring it once the shutdown reaches a decision.

@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m3

  • FLASH: .text +28 B (+0.0%, 125,675 B / 262,144 B, total: 48% used)

gcc-arm-cortex-m4

  • FLASH: .text +64 B (+0.0%, 204,335 B / 262,144 B, total: 78% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +64 B (+0.0%, 780,412 B / 1,048,576 B, total: 74% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +64 B (+0.0%, 331,504 B / 1,048,576 B, total: 32% used)

gcc-arm-cortex-m7

  • FLASH: .text +64 B (+0.0%, 204,335 B / 262,144 B, total: 78% used)

gcc-arm-cortex-m7-pq

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