Bug 16290 - An SMB2 CLOSE on a valid handle opened with `FILE_DELETE_ON_CLOSE` can return `STATUS_OBJECT_NAME_NOT_FOUND` after another smbd process successfully renames the file.
Summary: An SMB2 CLOSE on a valid handle opened with `FILE_DELETE_ON_CLOSE` can return...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.23.5
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-10-29 11:42 UTC by Biswajit Prasad
Modified: 2026-10-29 11:42 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Biswajit Prasad 2026-10-29 11:42:16 UTC
An SMB2 CLOSE on a valid handle opened with `FILE_DELETE_ON_CLOSE` can return
`STATUS_OBJECT_NAME_NOT_FOUND` after another smbd process successfully renames
the file. In the traced failure, the closing process receives the matching
`MSG_SMB_FILE_RENAME` notification while waiting for the mover's share-mode
lock, but defers its callback to the main event context. CLOSE resumes without
applying the notification, attempts to unlink the old pathname, and frees the
handle. The rename callback then runs and reports `fsp not found`.

The shared share-mode entries already contain the new name hash, while the
closing process retains the old local name/hash. This also affects the
other-open check used to decide whether to delete the file.

Steps to reproduce described issue:

1. Create a regular file `Folder/file` in an SMB share. The workload includes
   alternate data streams; also test without streams to determine whether they
   are necessary for reproduction.
2. Client A opens the base file for rename and keeps its handle open. Allow
   read/write/delete sharing and request the access needed for rename.
3. Client B opens the same base file with DELETE access,
   `FILE_DELETE_ON_CLOSE`, and read/write/delete sharing. Use a separate
   connection handled by another smbd process.
4. Client A sends `SET_INFO / FileRenameInformation` to move `Folder/file` to
   share-root `file` using its open handle.
5. While the rename is outstanding, Client B sends CLOSE on its own handle.
   The discriminating interleaving is that B waits for the share-mode lock held
   by A and receives the rename notification on the nested event context.
6. Client A closes its handle. Record both CLOSE results and inspect the old
   and new paths, including alternate streams, after both handles are closed.
7. Repeat while collecting level-10 logs. Merely sending CLOSE after the
   rename response may miss the contention window.


Expected Result

Concurrent successful rename must not leave CLOSE evaluating deletion against
an obsolete local name/hash. CLOSE should succeed for this valid-handle
sequence, preserve the applicable other-open/delete-on-close semantics, and
perform any required final deletion against the correct name. A rename alone
must not turn valid-handle CLOSE into a stale-path lookup failure.