Re: [RFC PATCH samba] smbd: deny rename if the destination has non-POSIX opens

Ralph Boehme <[email protected]>
Newsgroups org.kernel.vger.linux-cifs
Message-ID <[email protected]>
On 8/5/26 3:31 PM, ChenXiaoSong wrote:
> From: ChenXiaoSong <[email protected]>
> 
> Check the destination share mode entries with
> has_other_nonposix_opens() before replacing it, and return
> NT_STATUS_ACCESS_DENIED if a non-POSIX open exists.
thanks for looking into this!

I'm afraid though that the issue is more subtle then just adjusting the 
check in that place.

In fact, back when I implemented Directory Leases, I added the full 
logic to check for open files and possible H-leases on them on
- the src of the rename
- iirc also the parent of the src of the rename
- the parent of the dst
- and the dst

All that logic lives in a few levels avove rename_internals_fsp() inside 
smbd_smb2_setinfo_lease_break_check().

The function that deals with the dst is 
smbd_smb2_setinfo_rename_dst_check(). That one already correctly uses 
has_other_nonposix_opens() while holding a lock on the locking.tdb 
record of the destination.

The check with files_forall() inside rename_internals_fsp() is a clutch 
that already check for opens in the same process, not globally. And we 
can't expand it to be global, as that requires taking the lock on the 
locking.tdb record which is prohibitted by the fact that we already have 
the lck on the src when rename_internals_fsp() is called. Locking two 
records simultaneously is not allowed in Samba, as it could lead to 
deadlocks.

So I guess the best we can do is remove the redundant check altogether 
from rename_internals_fsp() and rely on the correct logic from 
smbd_smb2_setinfo_lease_break_check(). We have to live with the toctou 
race window anyway, it just enlarges the window a bit, but only for the 
case of open files by the same client. Opens from other clients, are not 
detected anyway by the files_forall() as said above.
OpenPGP_signature.asc (application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE-----

wsF5BAABCAAjFiEE+uLGCIokJSBRxVnkqh6bcSY5nkYFAmpzkGwFAwAAAAAACgkQqh6bcSY5nkZK
hw//TkIhoVgz6LSB31TWpPqYtp2HDMwHLXyWCavU1oaACTPdLA9R+zoyLDdTVKPP9piJsjXC8/Cl
62rtbqWTIc4QngPlyomASS2fnbTTuc9Twk2Q04A4a5Cypz7OQtkbYIWtyD6LBZMMEIfv5+OZ+nQH
LVMRHjeASxZ5ySayERo0ReEu4IIG+bJqKMr/mxmJmD+X+iG+DvHV/U8EY+JS0vRAq54tTd4Yv0Xq
Yqs0SIj4+iAI/8TzMJ41gMfzzGSLxe78mhHDBshUbNSi9Z0ZWWQ5/1g8/jyQ5U1HdaWvTUrqFw8A
aDF0xV8TnK30pb1jxUyLWxL7UJNqItkdv/c+H6nY2JZF4J9WybJSL+FrUZRUsciQhOgbmb+JjReQ
/i67RO+fKVg0qoYPhv2eb/5VJKCiqC7MXOFcWX2H9qOR7n+3yVC3sLwxQ5XhKD8SUrZMp9omTkJY
BeLchKx0+h9qwNMqQEBjat9vxucAgzLebEaHd3MVivlnwqm1LzhTByAj25+0bxbEOCqXVb/PN8qK
bSHrqei3IKcFkl36laVd81cxCmm9wCT99pyfoir+TQAbSpjTSnlikTaAlvR2owrk/HK2HAc3csdq
TIET4eeKs+wLIa4HskTJ21f+ki/EKXgBf8up9UXJrx2KGA7lLhRcJuC05Jdr5zjEkWjXyGelRSQ7
O3o=
=2+j2
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.