ksmbd: rework the DACL access check?
Subsystems (2)
Hi Namjae,
Now that the security descriptor codec (encoder/decoder) is in ksmbd-for-next, I'd like to rework the DACL access check in smb_check_perm_dacl().
Since April, 15 fixes have changed this function. Five dealt with bounds checks that the codec now handles. Ten changed what the function grants or denies. Some were about the DACL walk itself. Others were about how the DACL and the POSIX permissions combine. ksmbd has no single rule for that. smb_check_perm_dacl(), the inode_permission() calls in smb2_open(), and ksmbd_vfs_query_maximal_access() each decide a part of it.
I propose one access check for an existing file, built on one formula.
granted = (DACL rights | parent rights) & POSIX rights
The DACL rights come from one ordered walk of the stored DACL. The walk would use the uid and groups that ksmbd installs for the request and would match SIDs exactly. A file without a current stored DACL gets every DACL right, so the POSIX rights alone decide. The parent rights are DELETE and FILE_READ_ATTRIBUTES from the parent directory, as MS-FSA 2.1.5.1.2.1 describes. The POSIX rights are what the mode and the POSIX ACL allow, checked once for all the rights a request needs. WRITE_DAC and WRITE_OWNER need ownership of the file. A read-only share removes the write rights from a MAXIMUM_ALLOWED open. An unreadable DACL would still deny access.
An explicit open succeeds if the request is a subset of the result. A MAXIMUM_ALLOWED open and the maximal access reply both get the result. The app instance takeover and the hide unreadable listing would use the same check. The series would also settle how delete-on-close opens, overwrites, and the read-only attribute fit the same rule. The same rule would also decide creating, renaming, and linking a file, where today only the POSIX permissions of the target directory are checked.
Would you be open to an RFC series along those lines?
Thanks,
Ian
Namjae Jeon
maintainerQuoted 2 lines · Ian Bridges
Hi Namjae,
Hi Ian,
Quoted 36 lines
Now that the security descriptor codec (encoder/decoder) is in ksmbd-for-next, I'd like to rework the DACL access check in
smb_check_perm_dacl().Since April, 15 fixes have changed this function. Five dealt with bounds checks that the codec now handles. Ten changed what the function grants or denies. Some were about the DACL walk itself. Others were about how the DACL and the POSIX permissions combine. ksmbd has no single rule for that.
smb_check_perm_dacl(), theinode_permission()calls insmb2_open(), andksmbd_vfs_query_maximal_access()each decide a part of it.I propose one access check for an existing file, built on one formula.
granted = (DACL rights | parent rights) & POSIX rights
The DACL rights come from one ordered walk of the stored DACL. The walk would use the uid and groups that ksmbd installs for the request and would match SIDs exactly. A file without a current stored DACL gets every DACL right, so the POSIX rights alone decide. The parent rights are DELETE and
FILE_READ_ATTRIBUTESfrom the parent directory, as MS-FSA 2.1.5.1.2.1 describes. The POSIX rights are what the mode and the POSIX ACL allow, checked once for all the rights a request needs.WRITE_DACandWRITE_OWNERneed ownership of the file. A read-only share removes the write rights from aMAXIMUM_ALLOWEDopen. An unreadable DACL would still deny access.An explicit open succeeds if the request is a subset of the result. A
MAXIMUM_ALLOWEDopen and the maximal access reply both get the result. The app instance takeover and the hide unreadable listing would use the same check. The series would also settle how delete-on-close opens, overwrites, and the read-only attribute fit the same rule. The same rule would also decide creating, renaming, and linking a file, where today only the POSIX permissions of the target directory are checked.
Quoted 1 line
Would you be open to an RFC series along those lines?
I agree. Please verify that the relevant ACLs-related smbtorture tests pass after implementation.
Thanks for the work!