smbd: SMB2 Compound related chain handling when generation of FileId has failed
authorRalph Boehme <slow@samba.org>
Thu, 8 Apr 2021 10:17:22 +0000 (12:17 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 8 Apr 2021 17:30:50 +0000 (17:30 +0000)
commitfc6eba619eb91925513d0c62263db894faffd8d6
tree0270a49267f872e302be9f3e65c2f54245354475
parentb97b5ca0cbb9b58e968eac78c3baaa37e031067b
smbd: SMB2 Compound related chain handling when generation of FileId has failed

Issue:
We have a scenario where an application sends a Compound Related chain
consisting of:
SMB2_CREATE
SMB2_IOCTL
SMB2_SET_INFO
SMB2_CLOSE

SMB2_CREATE failed with NT_STATUS_ACCESS_DENIED and subsequent
requests all fail. In Samba they return NT_STATUS_FILE_CLOSED.

When I tried the same against a Win2k12 server, I noticed that all the
failed requests of the chain would return NT_STATUS_ACCESS_DENIED.

I believe this behaviour is also mentioned in the [MS-SMB2] Specs
3.3.5.2.7.2: Handling Compounded Related Requests

"When the current operation requires a FileId and the previous
operation either contains or generates a FileId, if the previous
operation fails with an error, the server SHOULD<223> fail the current
operation with the same error code returned by the previous
operation."

Fix:
Save NTATUS of a failed Create request. When we process subsequent
requests of the chain we check if the previous Create has failed. In
case of a Create failure we returned the saved NTSTATUS.

Signed-off-by: Anubhav Rakshit <anubhav.rakshit@gmail.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr  8 17:30:50 UTC 2021 on sn-devel-184
selftest/knownfail.d/samba3.smb2.compound [deleted file]
source3/smbd/globals.h
source3/smbd/smb2_create.c
source3/smbd/smb2_server.c