Repository navigation
smbserver: reply with SMB2 ERROR response on failed requests - #2380
Open
cielavenir wants to merge 1 commit into
Open
cielavenir wants to merge 1 commit into
cielavenir wants to merge 1 commit into
Conversation
[MS-SMB2] 3.3.4.4 requires failed requests to be answered with an
SMB2 ERROR Response (StructureSize 9). The server sent the command's
own empty response structure instead (e.g. SMB2 CREATE response with
STATUS_OBJECT_NAME_NOT_FOUND, TREE_CONNECT response for an unknown
share). Strict clients like libsmb2 fail to parse it ("Unexpected
size of Error reply") and drop the connection.
STATUS_MORE_PROCESSING_REQUIRED and STATUS_BUFFER_OVERFLOW keep the
command response body as the spec allows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cielavenir
marked this pull request as ready for review
November 17, 2026 04:24
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.
Problem
smbserveranswers failed SMB2 requests with the command's own (mostly empty) response structureinstead of an SMB2 ERROR Response. For example:
SMB2 CREATEfor a missing file returns anSMB2Create_Responsebody withSTATUS_OBJECT_NAME_NOT_FOUND.SMB2 TREE_CONNECTto an unknown share returns anSMB2TreeConnect_Responsebody withSTATUS_OBJECT_PATH_NOT_FOUND.[MS-SMB2] 3.3.4.4 requires failed requests to be answered with an SMB2 ERROR Response
(
StructureSize= 9). Strict clients reject the reply. For example, libsmb2fails with
Unexpected size of Error reply. Expected 9, got 8(orFailed to decrypt pduon newerdialects) and drops the connection, so a plain
statof a missing file breaks the whole sessioninstead of returning
ENOENT.Fix
SMBSERVER.processRequest, when building an SMB2 response whose status is notSTATUS_SUCCESS,STATUS_MORE_PROCESSING_REQUIREDorSTATUS_BUFFER_OVERFLOW(the statusesthat carry the command's own response body), send
SMB2Error()as the body.smb2TreeConnectbuilds its own packet, so it gets the same treatment for an unknown share.Testing
tests/SMB_RPC/test_smbserver.py: 45 passed, 3 skipped.A libsmb2 6.x client against
SimpleSMBServerwith SMB2 enabled:-1, connection dropped-ENOENT, connection stays up-1, connection dropped-ENOENTSTATUS_OBJECT_PATH_NOT_FOUND🤖 Generated with Claude Code