Re: [PATCH 1/4] cifs: Fix getting and setting SACLs over SMB1

From: Pali Rohár
Date: Fri Dec 27 2024 - 09:43:59 EST


On Sunday 22 December 2024 16:10:48 Pali Rohár wrote:
> diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
> index ba79aa2107cc..b07f3609adec 100644
> --- a/fs/smb/client/cifsacl.c
> +++ b/fs/smb/client/cifsacl.c
> @@ -1498,10 +1501,12 @@ int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen,
> tcon = tlink_tcon(tlink);
> xid = get_xid();
>
> - if (aclflag == CIFS_ACL_OWNER || aclflag == CIFS_ACL_GROUP)
> - access_flags = WRITE_OWNER;
> - else
> - access_flags = WRITE_DAC;
> + if (aclflag & CIFS_ACL_OWNER || aclflag & CIFS_ACL_GROUP)
> + access_flags |= WRITE_OWNER;
> + if (aclflag & CIFS_ACL_SACL)
> + access_flags |= SYSTEM_SECURITY;
> + if (aclflag & CIFS_ACL_DACL)
> + access_flags |= WRITE_DAC;
>
> oparms = (struct cifs_open_parms) {
> .tcon = tcon,

In this function is missing initialization of access_flags value after my change.
I can fix it by this simple fixup change:

diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index 1054c62ade6c..b3e2f1dad175 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -1488,7 +1488,7 @@ int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen,
{
int oplock = 0;
unsigned int xid;
- int rc, access_flags;
+ int rc, access_flags = 0;
struct cifs_tcon *tcon;
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);