Problem description File creation via SMB protocol in folders with ACL inheritance It has identified potential security leak or data access loss issue for files created from SMB clients. The issue may appear when SMB clients create files in folders that use ACL inheritance to change ACLs (additional access to groups, reduced access to a users primary group) from the default access mask. Detailed Description: To reproduce: 1) Have a directory with an NFSV4 ACL where permissions are inherited to at least new files, e.g like this: | # mmgetacl . | #NFSv4 ACL | #owner:<user> | #group:<group> | special:owner@:rwxc:allow:FileInherit:DirInherit:Inherited | (X)READ/LIST (X)WRITE/CREATE (X)APPEND/MKDIR (X)SYNCHRONIZE (X)READ_ACL (X)READ_ATTR (X)READ_NAMED | (X)DELETE (X)DELETE_CHILD (-)CHOWN (X)EXEC/SEARCH (X)WRITE_ACL (X)WRITE_ATTR (X)WRITE_NAMED | | special:group@:rwxc:allow:FileInherit:DirInherit:Inherited | (X)READ/LIST (X)WRITE/CREATE (X)APPEND/MKDIR (X)SYNCHRONIZE (X)READ_ACL (X)READ_ATTR (X)READ_NAMED | (X)DELETE (X)DELETE_CHILD (-)CHOWN (X)EXEC/SEARCH (X)WRITE_ACL (X)WRITE_ATTR (X)WRITE_NAMED | | special:everyone@:----:allow:FileInherit:DirInherit:Inherited | (-)READ/LIST (-)WRITE/CREATE (-)APPEND/MKDIR (-)SYNCHRONIZE (-)READ_ACL (-)READ_ATTR (-)READ_NAMED | (-)DELETE (-)DELETE_CHILD (-)CHOWN (-)EXEC/SEARCH (-)WRITE_ACL (-)WRITE_ATTR (-)WRITE_NAMED 2) From windows command line, where the SMB mounted directory is current directory, create a file the simplest way possible to exclude the possibility that some software overrrides permissions, e.g: | dir > dir.txt 3) Check the ACL for the new file: | # mmgetacl dir.txt 4) Has the new file inherited file permissions as it should, or is it the same wrong permissions we see? | #NFSv4 ACL | #owner:<user> | #group:<group> | #ACL flags: | # NULL_DACL | # NULL_SACL | special:owner@:rwxc:allow:Inherited | (X)READ/LIST (X)WRITE/CREATE (X)APPEND/MKDIR (X)SYNCHRONIZE (X)READ_ACL (X)READ_ATTR (X)READ_NAMED | (X)DELETE (X)DELETE_CHILD (-)CHOWN (X)EXEC/SEARCH (X)WRITE_ACL (X)WRITE_ATTR (X)WRITE_NAMED | | special:group@:r--c:allow:Inherited | (X)READ/LIST (-)WRITE/CREATE (-)APPEND/MKDIR (X)SYNCHRONIZE (X)READ_ACL (X)READ_ATTR (X)READ_NAMED | (X)DELETE (X)DELETE_CHILD (-)CHOWN (-)EXEC/SEARCH (X)WRITE_ACL (X)WRITE_ATTR (X)WRITE_NAMED | | special:everyone@:r---:allow:Inherited | (X)READ/LIST (-)WRITE/CREATE (-)APPEND/MKDIR (-)SYNCHRONIZE (-)READ_ACL (-)READ_ATTR (-)READ_NAMED | (-)DELETE (-)DELETE_CHILD (-)CHOWN (-)EXEC/SEARCH (-)WRITE_ACL (-)WRITE_ATTR (-)WRITE_NAMED Fix: unx_mode and st_ex_mode are compared and executing the SMB_VFS_FCHMOD which not expected, so unx_mode need to be set correctly in function possibly_set_archive.
Created attachment 18658 [details] unx_mode variable is set correctly with variable smb_fname->st.st_ex_mode
*** Bug 15879 has been marked as a duplicate of this bug. ***
(In reply to Srinivas Rao V from comment #1) Gna, looks like my fault. Change looks good! Can you create a MR on gitlab with this change, adding your signed-off to the commit message once you're happy with your patch?
While Srinivas does the paperwork, I run the patch successfully through our pipeline: https://gitlab.com/samba-team/devel/samba/-/commits/gd-mater-nfsv4acl-inheritance
see also #7987 and the fix introducing fchmod_acl_module_common (currently only used in acl_xattr)
This bug was referenced in samba master: 1d1acebf01902bef3a9ccae23c3be4cacbb777b2
(In reply to Ralph Böhme from comment #3) And I was the RB+. I'm sorry for missing that :-(.
Created attachment 18673 [details] patch from master for v4-22-test
Created attachment 18674 [details] patch from master for v4-21-test
*** Bug 15847 has been marked as a duplicate of this bug. ***
Reassigning to Jule for inclusion in 4.21, 4.22 and 4.23. The patch for 4.22 should apply to 4.23 as well (hopefully... :) )
Pushed to autobuild-v4-{22,21}-test. The fix is already in 4.23 :)
This bug was referenced in samba v4-21-test: 2278b6317b7dc3e19c69bd38936149441602b058
This bug was referenced in samba v4-22-test: af6d23f98919af8f6f802a9cf7410d1d4fb07288
Closing out bug report. Thanks!
This bug was referenced in samba v4-22-stable (Release samba-4.22.4): af6d23f98919af8f6f802a9cf7410d1d4fb07288
This bug was referenced in samba v4-21-stable (Release samba-4.21.8): 2278b6317b7dc3e19c69bd38936149441602b058