src/common: Do not assert on truncated buffers#12197
Open
sydidelot wants to merge 1 commit intoofiwg:mainfrom
Open
src/common: Do not assert on truncated buffers#12197sydidelot wants to merge 1 commit intoofiwg:mainfrom
sydidelot wants to merge 1 commit intoofiwg:mainfrom
Conversation
This patch replaces an assertion with proper error handling when a truncated control buffer is detected, returning an error to the caller instead of crashing the process. We observed crashes in debug builds of libfabric in the zero-copy code path when async send operations complete. The crash occurs when the kernel reports a truncated control message, triggering an assertion. According to the recvmsg(2) man page, msg_controllen should be updated on return to reflect the length of the received control data. However, GDB shows that the buffer is allocated with 48 bytes and msg_controllen remains unchanged after recvmsg() returns, suggesting that truncation should not have occurred. The root cause is currently unknown, and there is no clear evidence that increasing the control buffer size would resolve the issue. The zero-copy implementation matches existing implementations (e.g. QEMU, SPDK, and Linux kernel unit tests). Until the underlying issue is better understood, avoid asserting on truncated buffers and handle the condition gracefully by returning an error to the caller. This results in the endpoint being closed and the error reported back to the application. Signed-off-by: Sylvain Didelot <sdidelot@ddn.com>
Member
Author
|
If preferred, I can remove the return statement and let the function consume the data, though I'm not sure about the implications. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch replaces an assertion with proper error handling when a truncated control buffer is detected, returning an error to the caller instead of crashing the process.
We observed crashes in debug builds of libfabric in the zero-copy code path when async send operations complete. The crash occurs when the kernel reports a truncated control message, triggering an assertion.
According to the recvmsg(2) man page, msg_controllen should be updated on return to reflect the length of the received control data. However, GDB shows that the buffer is allocated with 48 bytes and msg_controllen remains unchanged after recvmsg() returns, suggesting that truncation should not have occurred.
The root cause is currently unknown, and there is no clear evidence that increasing the control buffer size would resolve the issue. The zero-copy implementation matches existing implementations (e.g. QEMU, SPDK, and Linux kernel unit tests).
Until the underlying issue is better understood, avoid asserting on truncated buffers and handle the condition gracefully by returning an error to the caller. This results in the endpoint being closed and the error reported back to the application.