smbd: Fix failure to check dstdir for delete on close
commit382a5c4e7ec08ec9291453ffad9541ab36aca274
authorVolker Lendecke <vl@samba.org>
Thu, 19 Nov 2020 11:38:06 +0000 (19 12:38 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 20 Nov 2020 00:20:06 +0000 (20 00:20 +0000)
tree64ff61cabf4161de623e2e213f6168a7cde551d7
parent0f67dd540fe11f6543ed759d3d947600c265e889
smbd: Fix failure to check dstdir for delete on close

In smb2_setinfo.c the call to smbd_do_setfilepathinfo() to perform the
rename takes place while holding a share mode lock. The function
check_parent_access() called below tries to query the destination
directory's locking.tdb entry to check whether the delete on close
flag is set on the destination directory. This fails because the
file to be renamed already has the share mode entry locked, we can't
lock two share mode entries simultaneously.

Convert the check to use fetch_share_mode_unlocked(). This might
introduce races, but this whole check is racy anyway. It does not
really matter whether we do the check for delete_on_close under a lock
or not, fetch_share_mode_unlocked() retrieves a consistent status of
the locking.tdb entry at some point in time as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Nov 20 00:20:06 UTC 2020 on sn-devel-184
selftest/knownfail.d/rename_to_del_on_close_dir [deleted file]
source3/smbd/open.c