The branch, v4-22-test has been updated
       via  d731cc875f2 vfs: Fix Bug 15791, vfs_acl_tdb unlinkat()
       via  34a2e467259 vfs: Fix a lock order violation in unlinkat_acl_tdb()
      from  a2f2a714848 smbd: fix handling of directory leases and oplock levels

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-22-test


- Log -----------------------------------------------------------------
commit d731cc875f2f14b9410141f983d993069bcd8f18
Author: Volker Lendecke <[email protected]>
Date:   Tue Jan 28 14:03:49 2025 +0100

    vfs: Fix Bug 15791, vfs_acl_tdb unlinkat()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=15791
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>
    (cherry picked from commit 93a6d36239dd2ce2b3863945f8b9b59cb6aa911a)
    
    Autobuild-User(v4-22-test): Jule Anger <[email protected]>
    Autobuild-Date(v4-22-test): Mon Mar 31 12:13:03 UTC 2025 on atb-devel-224

commit 34a2e467259cad93b12caaf2b7a4dbfa68f68929
Author: Volker Lendecke <[email protected]>
Date:   Wed Feb 26 16:04:01 2025 +0100

    vfs: Fix a lock order violation in unlinkat_acl_tdb()
    
    unlinkat is called when the share mode record is locked.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=15791
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>
    (cherry picked from commit 93bc238aa91ec8041648d17e11bf235132974eda)

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_acl_tdb.c | 51 ++++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c
index f2d2692159f..b054f159f87 100644
--- a/source3/modules/vfs_acl_tdb.c
+++ b/source3/modules/vfs_acl_tdb.c
@@ -58,7 +58,7 @@ static bool acl_tdb_init(void)
 
        become_root();
        acl_db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
-                        DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE);
+                        DBWRAP_LOCK_ORDER_2, DBWRAP_FLAG_NONE);
        unbecome_root();
 
        if (acl_db == NULL) {
@@ -195,38 +195,43 @@ static int unlinkat_acl_tdb(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        int flags)
 {
-       struct smb_filename *smb_fname_tmp = NULL;
-       struct db_context *db = acl_db;
-       int ret = -1;
-
-       smb_fname_tmp = cp_smb_filename_nostream(talloc_tos(), smb_fname);
-       if (smb_fname_tmp == NULL) {
-               errno = ENOMEM;
-               goto out;
-       }
+       struct stat_ex st = {};
+       int ret;
 
-       ret = vfs_stat(handle->conn, smb_fname_tmp);
-       if (ret == -1) {
-               goto out;
+       if (!is_named_stream(smb_fname)) {
+               if (VALID_STAT(smb_fname->st)) {
+                       st = smb_fname->st;
+               } else {
+                       ret = SMB_VFS_NEXT_FSTATAT(handle,
+                                                  dirfsp,
+                                                  smb_fname,
+                                                  &st,
+                                                  AT_SYMLINK_NOFOLLOW);
+                       if (ret == -1) {
+                               return ret;
+                       }
+               }
        }
 
        if (flags & AT_REMOVEDIR) {
-               ret = rmdir_acl_common(handle,
-                               dirfsp,
-                               smb_fname_tmp);
+               ret = rmdir_acl_common(handle, dirfsp, smb_fname);
        } else {
-               ret = unlink_acl_common(handle,
-                               dirfsp,
-                               smb_fname_tmp,
-                               flags);
+               ret = unlink_acl_common(handle, dirfsp, smb_fname, flags);
        }
 
        if (ret == -1) {
-               goto out;
+               return -1;
        }
 
-       acl_tdb_delete(handle, db, &smb_fname_tmp->st);
- out:
+       if (is_named_stream(smb_fname)) {
+               /*
+                * ACLs only stored for basenames
+                */
+               return ret;
+       }
+
+       acl_tdb_delete(handle, acl_db, &st);
+
        return ret;
 }
 


-- 
Samba Shared Repository

Reply via email to