smb: fix some bugs, move duplicate definitions to common header file, and some small cleanups
Subsystems (3)
[email protected]
reviewerv2 cover smb: fix some bugs, move duplicate definitions to common header file, and some small cleanups
From: ChenXiaoSong <[email protected]>
Fix some bugs in smb2_open() of smb server.
In order to maintain the code more easily, move some duplicate definitions to common header file.
Additionally, add some small cleanups to the patchset.
v1->v2:
- update patch #2 according to Namjae's suggestions.
- add patch #6~9 to rename 'cifs_ntsd' 'cifs_sid' 'cifs_acl' 'cifs_ace' according to Namjae's suggestions.
- add patch #12 to explained why the typo 'STATUS_MCA_OCCURED' was not corrected.
v1: https://lore.kernel.org/all/[email protected]/
ChenXiaoSong (12):
smb/server: fix return value of smb2_open() smb/server: fix potential null-ptr-deref of lease_ctx_info in
smb2_open()
smb/server: remove useless assignment of 'file_present' in smb2_open() smb/client: fix typo: GlobalMid_Sem -> GlobalMid_Lock smb/server: update misguided comment of smb2_allocate_rsp_buf() smb/client: rename cifs_ntsd to smb_ntsd
smb/client: rename cifs_sid to smb_sid
smb/client: rename cifs_acl to smb_acl
smb/client: rename cifs_ace to smb_ace
smb: move some duplicate definitions to common/smbacl.h
smb: move SMB2 Status code to common header file
smb: add comment to STATUS_MCA_OCCURED
fs/smb/client/cifsacl.c | 224 +--
fs/smb/client/cifsacl.h | 99 +-
fs/smb/client/cifsfs.c | 6 +-
fs/smb/client/cifsglob.h | 22 +-
fs/smb/client/cifsproto.h | 18 +-
fs/smb/client/cifssmb.c | 6 +-
fs/smb/client/smb2file.c | 2 +-
fs/smb/client/smb2inode.c | 6 +-
fs/smb/client/smb2maperror.c | 2 +-
fs/smb/client/smb2misc.c | 2 +-
fs/smb/client/smb2ops.c | 16 +-
fs/smb/client/smb2pdu.c | 14 +-
fs/smb/client/smb2pdu.h | 8 +-
fs/smb/client/smb2proto.h | 2 +-
fs/smb/client/smb2transport.c | 2 +-
fs/smb/client/xattr.c | 4 +-
fs/smb/{client => common}/smb2status.h | 6 +
fs/smb/common/smbacl.h | 121 ++
fs/smb/server/oplock.c | 4 +-
fs/smb/server/server.c | 2 +-
fs/smb/server/smb2misc.c | 2 +-
fs/smb/server/smb2pdu.c | 17 +-
fs/smb/server/smb_common.c | 2 +-
fs/smb/server/smbacl.h | 111 +-
fs/smb/server/smbstatus.h | 1822 ------------------------
fs/smb/server/transport_rdma.c | 2 +-
26 files changed, 314 insertions(+), 2208 deletions(-)
rename fs/smb/{client => common}/smb2status.h (99%)
create mode 100644 fs/smb/common/smbacl.h
delete mode 100644 fs/smb/server/smbstatus.hSignature · 1 line
2.34.1
[email protected]
reviewerPATCH v2 1/12 smb/server: fix return value of smb2_open()
From: ChenXiaoSong <[email protected]>
In most error cases, error code is not returned in smb2_open(), __process_request() will not print error message.
Fix this by returning the correct value at the end of smb2_open().
--- fs/smb/server/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +1 -1
@@ -3710,7 +3710,7 @@ int smb2_open(struct ksmbd_work *work)kfree (name);kfree (lc); -return 0 ; +return rc; }static int readdir_info_level_struct_sz (int info_level)
Signature · 1 line
2.34.1
Re: [PATCH v2 01/12] smb/server: fix return value of smb2_open()
Quoted 10 lines · On Thu, Aug 22, 2024 at 5:22 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
In most error cases, error code is not returned in
smb2_open(),__process_request()will not print error message.Fix this by returning the correct value at the end of
smb2_open().Signed-off-by ChenXiaoSong <[email protected]>Acked-by Namjae Jeon <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks.
[email protected]
reviewerPATCH v2 2/12 smb/server: fix potential null-ptr-deref of lease_ctx_info in smb2_open()
In reply to [email protected]From: ChenXiaoSong <[email protected]>
null-ptr-deref will occur when (req_op_level == SMB2_OPLOCK_LEVEL_LEASE) and parse_lease_state() return NULL.
Fix this by check if 'lease_ctx_info' is NULL.
Additionally, remove the redundant parentheses inparse_durable_handle_context().
--- fs/smb/server/oplock.c | 2 +- fs/smb/server/smb2pdu.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
fs/smb/server/oplock.c +1 -1
@@ -1510,7 +1510,7 @@ void create_lease_buf(u8 *rbuf, struct lease *lease)* parse_lease_state() - parse lease context containted in file open request * @open_req: buffer containing smb2 file open(create) request * -* Return: oplock state, -ENOENT if create lease context not found +* Return: allocated lease context object on success, otherwise NULL */ struct lease_ctx_info *parse_lease_state (void *open_req) {
fs/smb/server/smb2pdu.c +5 -5
@@ -2767,8 +2767,8 @@ static int parse_durable_handle_context(struct ksmbd_work *work, } } -if (((lc && (lc->req_state &SMB2_LEASE_HANDLE_CACHING_LE )) || - req_op_level ==SMB2_OPLOCK_LEVEL_BATCH )) { +if ((lc && (lc->req_state &SMB2_LEASE_HANDLE_CACHING_LE )) || + req_op_level ==SMB2_OPLOCK_LEVEL_BATCH ) { dh_info->CreateGuid = durable_v2_blob->CreateGuid; dh_info->persistent =
@@ -2788,8 +2788,8 @@ static int parse_durable_handle_context(struct ksmbd_work *work, goto out; } -if (((lc && (lc->req_state &SMB2_LEASE_HANDLE_CACHING_LE )) || - req_op_level ==SMB2_OPLOCK_LEVEL_BATCH )) { +if ((lc && (lc->req_state &SMB2_LEASE_HANDLE_CACHING_LE )) || + req_op_level ==SMB2_OPLOCK_LEVEL_BATCH ) {ksmbd_debug (SMB ,"Request for durable open\n" ); dh_info->type = dh_idx; }
@@ -3411,7 +3411,7 @@ int smb2_open(struct ksmbd_work *work) goto err_out1; } }else { -if (req_op_level ==SMB2_OPLOCK_LEVEL_LEASE ) { +if (req_op_level ==SMB2_OPLOCK_LEVEL_LEASE && lc) {if (S_ISDIR (file_inode (filp)->i_mode)) { lc->req_state &= ~SMB2_LEASE_WRITE_CACHING_LE ; lc->is_dir = true;
Signature · 1 line
2.34.1
Re: [PATCH v2 02/12] smb/server: fix potential null-ptr-deref of lease_ctx_info in smb2_open()
Quoted 6 lines · On Thu, Aug 22, 2024 at 5:22 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
null-ptr-deref will occur when (
req_op_level==SMB2_OPLOCK_LEVEL_LEASE) andparse_lease_state()return NULL.
Quoted 6 lines
Fix this by check if '
lease_ctx_info' is NULL.Additionally, remove the redundant parentheses in
parse_durable_handle_context().Signed-off-by ChenXiaoSong <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks.
[email protected]
reviewerPATCH v2 3/12 smb/server: remove useless assignment of 'file_present' in smb2_open()
In reply to [email protected]From: ChenXiaoSong <[email protected]>
The variable is already true here.
--- fs/smb/server/smb2pdu.c | 1 - 1 file changed, 1 deletion(-)
fs/smb/server/smb2pdu.c +0 -1
@@ -3093,7 +3093,6 @@ int smb2_open(struct ksmbd_work *work) goto err_out; } - file_present = true; idmap =mnt_idmap (path.mnt); }else {if (rc != -ENOENT )
Signature · 1 line
2.34.1
Re: [PATCH v2 03/12] smb/server: remove useless assignment of 'file_present' in smb2_open()
Quoted 7 lines · On Thu, Aug 22, 2024 at 5:22 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
The variable is already true here.
Signed-off-by ChenXiaoSong <[email protected]>Acked-by Namjae Jeon <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks.
[email protected]
reviewerPATCH v2 4/12 smb/client: fix typo: GlobalMid_Sem -> GlobalMid_Lock
In reply to [email protected]From: ChenXiaoSong <[email protected]>
The comments have typos, fix that to not confuse readers.
--- fs/smb/client/cifsfs.c | 6 +++--- fs/smb/client/cifsglob.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
fs/smb/client/cifsfs.c +3 -3
@@ -75,9 +75,9 @@ unsigned int sign_CIFS_PDUs = 1;/* * Global transaction id (XID) information */ -unsigned int GlobalCurrentXid;/* protected by GlobalMid_Sem */ -unsigned int GlobalTotalActiveXid;/* prot by GlobalMid_Sem */ -unsigned int GlobalMaxActiveXid;/* prot by GlobalMid_Sem */ +unsigned int GlobalCurrentXid;/* protected by GlobalMid_Lock */ +unsigned int GlobalTotalActiveXid;/* prot by GlobalMid_Lock */ +unsigned int GlobalMaxActiveXid;/* prot by GlobalMid_Lock */ spinlock_t GlobalMid_Lock;/* protects above & list operations on midQ entries */ /*
fs/smb/client/cifsglob.h +3 -3
@@ -2017,9 +2017,9 @@ extern spinlock_t cifs_tcp_ses_lock;/* * Global transaction id (XID) information */ -extern unsigned int GlobalCurrentXid;/* protected by GlobalMid_Sem */ -extern unsigned int GlobalTotalActiveXid;/* prot by GlobalMid_Sem */ -extern unsigned int GlobalMaxActiveXid;/* prot by GlobalMid_Sem */ +extern unsigned int GlobalCurrentXid;/* protected by GlobalMid_Lock */ +extern unsigned int GlobalTotalActiveXid;/* prot by GlobalMid_Lock */ +extern unsigned int GlobalMaxActiveXid;/* prot by GlobalMid_Lock */ extern spinlock_t GlobalMid_Lock;/* protects above & list operations on midQ entries */ /*
Signature · 1 line
2.34.1
[email protected]
reviewerPATCH v2 5/12 smb/server: update misguided comment of smb2_allocate_rsp_buf()
In reply to [email protected]From: ChenXiaoSong <[email protected]>
smb2_allocate_rsp_buf() will return other error code except -ENOMEM.
--- fs/smb/server/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +1 -1
@@ -519,7 +519,7 @@ int init_smb2_rsp_hdr(struct ksmbd_work *work)* smb2_allocate_rsp_buf() - allocate smb2 response buffer * @work: smb work containing smb request buffer * -* Return: 0 on success, otherwise -ENOMEM +* Return: 0 on success, otherwise error */ int smb2_allocate_rsp_buf (struct ksmbd_work *work) {
Signature · 1 line
2.34.1
Re: [PATCH v2 05/12] smb/server: update misguided comment of smb2_allocate_rsp_buf()
Quoted 7 lines · On Thu, Aug 22, 2024 at 5:22 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
smb2_allocate_rsp_buf()will return other error code except-ENOMEM.Signed-off-by ChenXiaoSong <[email protected]>Acked-by Namjae Jeon <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks.
[email protected]
reviewerPATCH v2 6/12 smb/client: rename cifs_ntsd to smb_ntsd
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \
's/struct cifs_ntsd/struct smb_ntsd/g' {} +--- fs/smb/client/cifsacl.c | 36 ++++++++++++++++++------------------ fs/smb/client/cifsacl.h | 6 +++--- fs/smb/client/cifsglob.h | 6 +++--- fs/smb/client/cifsproto.h | 10 +++++----- fs/smb/client/cifssmb.c | 6 +++--- fs/smb/client/smb2ops.c | 14 +++++++------- fs/smb/client/smb2pdu.c | 2 +- fs/smb/client/smb2proto.h | 2 +- fs/smb/client/xattr.c | 4 ++-- 9 files changed, 43 insertions(+), 43 deletions(-)
fs/smb/client/cifsacl.c +18 -18
@@ -515,8 +515,8 @@ exit_cifs_idmap(void) }/* copy ntsd, owner sid, and group sid from a security descriptor to another */ -static __u32 copy_sec_desc (const struct cifs_ntsd *pntsd, -struct cifs_ntsd *pnntsd, +static __u32 copy_sec_desc (const struct smb_ntsd *pntsd, +struct smb_ntsd *pnntsd,__u32 sidsoffset,struct cifs_sid *pownersid,struct cifs_sid *pgrpsid)
@@ -527,7 +527,7 @@ static __u32 copy_sec_desc(const struct cifs_ntsd *pntsd,/* copy security descriptor control portion */ pnntsd->revision = pntsd->revision; pnntsd->type = pntsd->type; - pnntsd->dacloffset =cpu_to_le32 (sizeof (struct cifs_ntsd )); + pnntsd->dacloffset =cpu_to_le32 (sizeof (struct smb_ntsd )); pnntsd->sacloffset =0 ; pnntsd->osidoffset =cpu_to_le32 (sidsoffset); pnntsd->gsidoffset =cpu_to_le32 (sidsoffset +sizeof (struct cifs_sid ));
@@ -1191,7 +1191,7 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl)/* Convert CIFS ACL to POSIX form */ static int parse_sec_desc (struct cifs_sb_info *cifs_sb, -struct cifs_ntsd *pntsd,int acl_len,struct cifs_fattr *fattr, +struct smb_ntsd *pntsd,int acl_len,struct cifs_fattr *fattr,bool get_mode_from_special_sid) {int rc =0 ;
@@ -1249,7 +1249,7 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb, }/* Convert permission bits from mode to equivalent CIFS ACL */ -static int build_sec_desc (struct cifs_ntsd *pntsd,struct cifs_ntsd *pnntsd, +static int build_sec_desc (struct smb_ntsd *pntsd,struct smb_ntsd *pnntsd,__u32 secdesclen,__u32 *pnsecdesclen,__u64 *pnmode,kuid_t uid,kgid_t gid,bool mode_from_sid,bool id_from_sid,int *aclflag) {
@@ -1279,7 +1279,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, le32_to_cpu(pntsd->gsidoffset));if (pnmode && *pnmode !=NO_CHANGE_64 ) {/* chmod */ - ndacloffset =sizeof (struct cifs_ntsd ); + ndacloffset =sizeof (struct smb_ntsd ); ndacl_ptr = (struct cifs_acl *)((char *)pnntsd + ndacloffset); ndacl_ptr->revision = dacloffset ? dacl_ptr->revision :cpu_to_le16 (ACL_REVISION );
@@ -1297,7 +1297,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, *aclflag |=CIFS_ACL_DACL ; }else { - ndacloffset =sizeof (struct cifs_ntsd ); + ndacloffset =sizeof (struct smb_ntsd ); ndacl_ptr = (struct cifs_acl *)((char *)pnntsd + ndacloffset); ndacl_ptr->revision = dacloffset ? dacl_ptr->revision :cpu_to_le16 (ACL_REVISION );
@@ -1385,11 +1385,11 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, }#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY -struct cifs_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *cifs_sb, +struct smb_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *cifs_sb,const struct cifs_fid *cifsfid,u32 *pacllen,u32 __maybe_unused unused) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;unsigned int xid;int rc;struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);
@@ -1410,10 +1410,10 @@ struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,return pntsd; } -static struct cifs_ntsd *get_cifs_acl_by_path (struct cifs_sb_info *cifs_sb, +static struct smb_ntsd *get_cifs_acl_by_path (struct cifs_sb_info *cifs_sb,const char *path,u32 *pacllen) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;int oplock =0 ;unsigned int xid;int rc;
@@ -1454,11 +1454,11 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, }/* Retrieve an ACL from the server */ -struct cifs_ntsd *get_cifs_acl (struct cifs_sb_info *cifs_sb, +struct smb_ntsd *get_cifs_acl (struct cifs_sb_info *cifs_sb,struct inode *inode,const char *path,u32 *pacllen,u32 info) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;struct cifsFileInfo *open_file =NULL ;if (inode)
@@ -1472,7 +1472,7 @@ struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, }/* Set an ACL on the server */ -int set_cifs_acl (struct cifs_ntsd *pnntsd,__u32 acllen, +int set_cifs_acl (struct smb_ntsd *pnntsd,__u32 acllen,struct inode *inode,const char *path,int aclflag) {int oplock =0 ;
@@ -1528,7 +1528,7 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, struct inode *inode, bool mode_from_special_sid, const char *path, const struct cifs_fid *pfid) { - struct cifs_ntsd *pntsd = NULL; + struct smb_ntsd *pntsd = NULL;u32 acllen =0 ;int rc =0 ;struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);
@@ -1581,8 +1581,8 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,__u32 nsecdesclen =0 ;__u32 dacloffset =0 ;struct cifs_acl *dacl_ptr =NULL ; -struct cifs_ntsd *pntsd =NULL ;/* acl obtained from server */ -struct cifs_ntsd *pnntsd =NULL ;/* modified acl to be sent to server */ +struct smb_ntsd *pntsd =NULL ;/* acl obtained from server */ +struct smb_ntsd *pnntsd =NULL ;/* modified acl to be sent to server */ struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);struct smb_version_operations *ops;
@@ -1630,7 +1630,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, nsecdesclen +=5 *sizeof (struct cifs_ace ); }else {/* chown */ /* When ownership changes, changes new owner sid length could be different */ - nsecdesclen =sizeof (struct cifs_ntsd ) + (sizeof (struct cifs_sid ) *2 ); + nsecdesclen =sizeof (struct smb_ntsd ) + (sizeof (struct cifs_sid ) *2 ); dacloffset =le32_to_cpu (pntsd->dacloffset);if (dacloffset) { dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset);
fs/smb/client/cifsacl.h +3 -3
@@ -33,7 +33,7 @@* Security Descriptor length containing DACL with 3 ACEs (one each for * owner, group and world). */ -#define DEFAULT_SEC_DESC_LEN (sizeof(struct cifs_ntsd) + \ +#define DEFAULT_SEC_DESC_LEN (sizeof(struct smb_ntsd) + \ sizeof(struct cifs_acl) + \ (sizeof(struct cifs_ace) * 4))
@@ -55,7 +55,7 @@#define SID_STRING_BASE_SIZE (2 + 3 + 15 + 1)#define SID_STRING_SUBAUTH_SIZE (11)/* size of a single subauth string */ -struct cifs_ntsd { +struct smb_ntsd {__le16 revision;/* revision level */ __le16 type;__le32 osidoffset;
@@ -194,6 +194,6 @@ struct owner_group_sids {* Minimum security descriptor can be one without any SACL and DACL and can * consist of revision, type, and two sids of minimum size for owner and group */ -#define MIN_SEC_DESC_LEN (sizeof(struct cifs_ntsd) + (2 * MIN_SID_LEN)) +#define MIN_SEC_DESC_LEN (sizeof(struct smb_ntsd) + (2 * MIN_SID_LEN))#endif /* _CIFSACL_H */
fs/smb/client/cifsglob.h +3 -3
@@ -537,11 +537,11 @@ struct smb_version_operations {int (*set_EA)(const unsigned int ,struct cifs_tcon *,const char *,const char *,const void *,const __u16 ,const struct nls_table *,struct cifs_sb_info *); -struct cifs_ntsd * (*get_acl)(struct cifs_sb_info *,struct inode *, +struct smb_ntsd * (*get_acl)(struct cifs_sb_info *,struct inode *,const char *,u32 *,u32 ); -struct cifs_ntsd * (*get_acl_by_fid)(struct cifs_sb_info *, +struct smb_ntsd * (*get_acl_by_fid)(struct cifs_sb_info *,const struct cifs_fid *,u32 *,u32 ); -int (*set_acl)(struct cifs_ntsd *,__u32 ,struct inode *,const char *, +int (*set_acl)(struct smb_ntsd *,__u32 ,struct inode *,const char *,int );/* writepages retry size */ unsigned int (*wp_retry_size)(struct inode *);
fs/smb/client/cifsproto.h +5 -5
@@ -233,15 +233,15 @@ extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, const char *path, const struct cifs_fid *pfid);extern int id_mode_to_cifs_acl (struct inode *inode,const char *path,__u64 *pnmode,kuid_t uid,kgid_t gid); -extern struct cifs_ntsd *get_cifs_acl (struct cifs_sb_info *,struct inode *, +extern struct smb_ntsd *get_cifs_acl (struct cifs_sb_info *,struct inode *,const char *,u32 *,u32 ); -extern struct cifs_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *, +extern struct smb_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *,const struct cifs_fid *,u32 *,u32 );extern struct posix_acl *cifs_get_acl (struct mnt_idmap *idmap,struct dentry *dentry,int type);extern int cifs_set_acl (struct mnt_idmap *idmap,struct dentry *dentry,struct posix_acl *acl,int type); -extern int set_cifs_acl (struct cifs_ntsd *,__u32 ,struct inode *, +extern int set_cifs_acl (struct smb_ntsd *,__u32 ,struct inode *,const char *,int );extern unsigned int setup_authusers_ACE (struct cifs_ace *pace);extern unsigned int setup_special_mode_ACE (struct cifs_ace *pace,__u64 nmode);
@@ -570,9 +570,9 @@ extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,const struct nls_table *nls_codepage, struct cifs_sb_info *cifs_sb);extern int CIFSSMBGetCIFSACL (const unsigned int xid,struct cifs_tcon *tcon, -__u16 fid,struct cifs_ntsd **acl_inf,__u32 *buflen); +__u16 fid,struct smb_ntsd **acl_inf,__u32 *buflen);extern int CIFSSMBSetCIFSACL (const unsigned int ,struct cifs_tcon *,__u16 , -struct cifs_ntsd *,__u32 ,int ); +struct smb_ntsd *,__u32 ,int ); extern int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon, const unsigned char *searchName, struct posix_acl **acl, const int acl_type,
fs/smb/client/cifssmb.c +3 -3
@@ -3391,7 +3391,7 @@ validate_ntransact(char *buf, char **ppparm, char **ppdata,/* Get Security Descriptor (by handle) from remote server for a file or dir */ int CIFSSMBGetCIFSACL (const unsigned int xid,struct cifs_tcon *tcon,__u16 fid, -struct cifs_ntsd **acl_inf,__u32 *pbuflen) +struct smb_ntsd **acl_inf,__u32 *pbuflen) {int rc =0 ;int buf_type =0 ;
@@ -3461,7 +3461,7 @@ CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid,/* check if buffer is big enough for the acl header followed by the smallest SID */ -if ((*pbuflen <sizeof (struct cifs_ntsd ) +8 ) || +if ((*pbuflen <sizeof (struct smb_ntsd ) +8 ) || (*pbuflen >=64 *1024 )) {cifs_dbg (VFS ,"bad acl length %d\n" , *pbuflen); rc = -EINVAL ;
@@ -3481,7 +3481,7 @@ CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid,int CIFSSMBSetCIFSACL (const unsigned int xid,struct cifs_tcon *tcon,__u16 fid, -struct cifs_ntsd *pntsd,__u32 acllen,int aclflag) +struct smb_ntsd *pntsd,__u32 acllen,int aclflag) {__u16 byte_count, param_count, data_count, param_offset, data_offset;int rc =0 ;
fs/smb/client/smb2ops.c +7 -7
@@ -3046,11 +3046,11 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,return rc; } -static struct cifs_ntsd * +static struct smb_ntsd *get_smb2_acl_by_fid (struct cifs_sb_info *cifs_sb,const struct cifs_fid *cifsfid,u32 *pacllen,u32 info) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;unsigned int xid;int rc = -EOPNOTSUPP ;struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);
@@ -3075,11 +3075,11 @@ get_smb2_acl_by_fid(struct cifs_sb_info *cifs_sb, } -static struct cifs_ntsd * +static struct smb_ntsd *get_smb2_acl_by_path (struct cifs_sb_info *cifs_sb,const char *path,u32 *pacllen,u32 info) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;u8 oplock =SMB2_OPLOCK_LEVEL_NONE ;unsigned int xid;int rc;
@@ -3142,7 +3142,7 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb, }static int -set_smb2_acl (struct cifs_ntsd *pnntsd,__u32 acllen, +set_smb2_acl (struct smb_ntsd *pnntsd,__u32 acllen,struct inode *inode,const char *path,int aclflag) {u8 oplock =SMB2_OPLOCK_LEVEL_NONE ;
@@ -3200,12 +3200,12 @@ set_smb2_acl(struct cifs_ntsd *pnntsd, __u32 acllen, }/* Retrieve an ACL from the server */ -static struct cifs_ntsd * +static struct smb_ntsd *get_smb2_acl (struct cifs_sb_info *cifs_sb,struct inode *inode,const char *path,u32 *pacllen,u32 info) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;struct cifsFileInfo *open_file =NULL ;if (inode && !(info &SACL_SECINFO ))
fs/smb/client/smb2pdu.c +1 -1
@@ -5674,7 +5674,7 @@ SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,int SMB2_set_acl (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid, -struct cifs_ntsd *pnntsd,int pacllen,int aclflag) +struct smb_ntsd *pnntsd,int pacllen,int aclflag) { return send_set_info(xid, tcon, persistent_fid, volatile_fid, current->tgid, 0, SMB2_O_INFO_SECURITY, aclflag,
fs/smb/client/smb2proto.h +1 -1
@@ -238,7 +238,7 @@ extern int SMB2_set_info_init(struct cifs_tcon *tcon,extern void SMB2_set_info_free (struct smb_rqst *rqst);extern int SMB2_set_acl (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid, -struct cifs_ntsd *pnntsd,int pacllen,int aclflag); +struct smb_ntsd *pnntsd,int pacllen,int aclflag);extern int SMB2_set_ea (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid,struct smb2_file_full_ea_info *buf,int len);
fs/smb/client/xattr.c +2 -2
@@ -162,7 +162,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler,case XATTR_CIFS_ACL :case XATTR_CIFS_NTSD :case XATTR_CIFS_NTSD_FULL : { -struct cifs_ntsd *pacl; +struct smb_ntsd *pacl;if (!value) goto out;
@@ -315,7 +315,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,* fetch owner and DACL otherwise */ u32 acllen, extra_info; -struct cifs_ntsd *pacl; +struct smb_ntsd *pacl;if (pTcon->ses->server->ops->get_acl ==NULL ) goto out;/* rc already EOPNOTSUPP */
Signature · 1 line
2.34.1
Re: [PATCH v2 06/12] smb/client: rename cifs_ntsd to smb_ntsd
Quoted 11 lines · On Thu, Aug 22, 2024 at 5:23 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \ 's/struct cifs_ntsd/struct smb_ntsd/g' {} +Signed-off-by ChenXiaoSong <[email protected]>
Looks good to me.
Thanks.
Steve French
Reviewed-by Namjae JeonRe: [PATCH v2 06/12] smb/client: rename cifs_ntsd to smb_ntsd
Fixed various checkpatch warnings e.g.
WARNING: function definition argument 'u32' should also have an
identifier name
see updated patch, and applied to cifs-2.6.git for-next
Quoted 17 lines · Namjae Jeon
Quoted 11 lines · On Thu, Aug 22, 2024 at 5:23 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \ 's/struct cifs_ntsd/struct smb_ntsd/g' {} +Signed-off-by ChenXiaoSong <[email protected]>Looks good to me.
Reviewed-by Namjae Jeon <[email protected]>Thanks.
Signature · 3 lines
Thanks, Steve
From 8335848d54c132aa7868e901fb69a062e582fd8d Mon Sep 17 00:00:00 2001
From: ChenXiaoSong <[email protected]>
Date: Thu, 22 Aug 2024 08:20:55 +0000
Subject: [PATCH] smb/client: rename cifs_ntsd to smb_ntsd
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \
's/struct cifs_ntsd/struct smb_ntsd/g' {} +--- fs/smb/client/cifsacl.c | 36 ++++++++++++++++++------------------ fs/smb/client/cifsacl.h | 6 +++--- fs/smb/client/cifsglob.h | 12 ++++++------ fs/smb/client/cifsproto.h | 16 ++++++++-------- fs/smb/client/cifssmb.c | 6 +++--- fs/smb/client/smb2ops.c | 14 +++++++------- fs/smb/client/smb2pdu.c | 2 +- fs/smb/client/smb2proto.h | 2 +- fs/smb/client/xattr.c | 4 ++-- 9 files changed, 49 insertions(+), 49 deletions(-)
fs/smb/client/cifsacl.c +18 -18
@@ -515,8 +515,8 @@ exit_cifs_idmap(void) }/* copy ntsd, owner sid, and group sid from a security descriptor to another */ -static __u32 copy_sec_desc (const struct cifs_ntsd *pntsd, -struct cifs_ntsd *pnntsd, +static __u32 copy_sec_desc (const struct smb_ntsd *pntsd, +struct smb_ntsd *pnntsd,__u32 sidsoffset,struct cifs_sid *pownersid,struct cifs_sid *pgrpsid)
@@ -527,7 +527,7 @@ static __u32 copy_sec_desc(const struct cifs_ntsd *pntsd,/* copy security descriptor control portion */ pnntsd->revision = pntsd->revision; pnntsd->type = pntsd->type; - pnntsd->dacloffset =cpu_to_le32 (sizeof (struct cifs_ntsd )); + pnntsd->dacloffset =cpu_to_le32 (sizeof (struct smb_ntsd )); pnntsd->sacloffset =0 ; pnntsd->osidoffset =cpu_to_le32 (sidsoffset); pnntsd->gsidoffset =cpu_to_le32 (sidsoffset +sizeof (struct cifs_sid ));
@@ -1191,7 +1191,7 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl)/* Convert CIFS ACL to POSIX form */ static int parse_sec_desc (struct cifs_sb_info *cifs_sb, -struct cifs_ntsd *pntsd,int acl_len,struct cifs_fattr *fattr, +struct smb_ntsd *pntsd,int acl_len,struct cifs_fattr *fattr,bool get_mode_from_special_sid) {int rc =0 ;
@@ -1249,7 +1249,7 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb, }/* Convert permission bits from mode to equivalent CIFS ACL */ -static int build_sec_desc (struct cifs_ntsd *pntsd,struct cifs_ntsd *pnntsd, +static int build_sec_desc (struct smb_ntsd *pntsd,struct smb_ntsd *pnntsd,__u32 secdesclen,__u32 *pnsecdesclen,__u64 *pnmode,kuid_t uid,kgid_t gid,bool mode_from_sid,bool id_from_sid,int *aclflag) {
@@ -1279,7 +1279,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, le32_to_cpu(pntsd->gsidoffset));if (pnmode && *pnmode !=NO_CHANGE_64 ) {/* chmod */ - ndacloffset =sizeof (struct cifs_ntsd ); + ndacloffset =sizeof (struct smb_ntsd ); ndacl_ptr = (struct cifs_acl *)((char *)pnntsd + ndacloffset); ndacl_ptr->revision = dacloffset ? dacl_ptr->revision :cpu_to_le16 (ACL_REVISION );
@@ -1297,7 +1297,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, *aclflag |=CIFS_ACL_DACL ; }else { - ndacloffset =sizeof (struct cifs_ntsd ); + ndacloffset =sizeof (struct smb_ntsd ); ndacl_ptr = (struct cifs_acl *)((char *)pnntsd + ndacloffset); ndacl_ptr->revision = dacloffset ? dacl_ptr->revision :cpu_to_le16 (ACL_REVISION );
@@ -1385,11 +1385,11 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, }#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY -struct cifs_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *cifs_sb, +struct smb_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *cifs_sb,const struct cifs_fid *cifsfid,u32 *pacllen,u32 __maybe_unused unused) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;unsigned int xid;int rc;struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);
@@ -1410,10 +1410,10 @@ struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,return pntsd; } -static struct cifs_ntsd *get_cifs_acl_by_path (struct cifs_sb_info *cifs_sb, +static struct smb_ntsd *get_cifs_acl_by_path (struct cifs_sb_info *cifs_sb,const char *path,u32 *pacllen) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;int oplock =0 ;unsigned int xid;int rc;
@@ -1454,11 +1454,11 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, }/* Retrieve an ACL from the server */ -struct cifs_ntsd *get_cifs_acl (struct cifs_sb_info *cifs_sb, +struct smb_ntsd *get_cifs_acl (struct cifs_sb_info *cifs_sb,struct inode *inode,const char *path,u32 *pacllen,u32 info) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;struct cifsFileInfo *open_file =NULL ;if (inode)
@@ -1472,7 +1472,7 @@ struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, }/* Set an ACL on the server */ -int set_cifs_acl (struct cifs_ntsd *pnntsd,__u32 acllen, +int set_cifs_acl (struct smb_ntsd *pnntsd,__u32 acllen,struct inode *inode,const char *path,int aclflag) {int oplock =0 ;
@@ -1528,7 +1528,7 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, struct inode *inode, bool mode_from_special_sid, const char *path, const struct cifs_fid *pfid) { - struct cifs_ntsd *pntsd = NULL; + struct smb_ntsd *pntsd = NULL;u32 acllen =0 ;int rc =0 ;struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);
@@ -1581,8 +1581,8 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,__u32 nsecdesclen =0 ;__u32 dacloffset =0 ;struct cifs_acl *dacl_ptr =NULL ; -struct cifs_ntsd *pntsd =NULL ;/* acl obtained from server */ -struct cifs_ntsd *pnntsd =NULL ;/* modified acl to be sent to server */ +struct smb_ntsd *pntsd =NULL ;/* acl obtained from server */ +struct smb_ntsd *pnntsd =NULL ;/* modified acl to be sent to server */ struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);struct smb_version_operations *ops;
@@ -1630,7 +1630,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, nsecdesclen +=5 *sizeof (struct cifs_ace ); }else {/* chown */ /* When ownership changes, changes new owner sid length could be different */ - nsecdesclen =sizeof (struct cifs_ntsd ) + (sizeof (struct cifs_sid ) *2 ); + nsecdesclen =sizeof (struct smb_ntsd ) + (sizeof (struct cifs_sid ) *2 ); dacloffset =le32_to_cpu (pntsd->dacloffset);if (dacloffset) { dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset);
fs/smb/client/cifsacl.h +3 -3
@@ -33,7 +33,7 @@* Security Descriptor length containing DACL with 3 ACEs (one each for * owner, group and world). */ -#define DEFAULT_SEC_DESC_LEN (sizeof(struct cifs_ntsd) + \ +#define DEFAULT_SEC_DESC_LEN (sizeof(struct smb_ntsd) + \ sizeof(struct cifs_acl) + \ (sizeof(struct cifs_ace) * 4))
@@ -55,7 +55,7 @@#define SID_STRING_BASE_SIZE (2 + 3 + 15 + 1)#define SID_STRING_SUBAUTH_SIZE (11)/* size of a single subauth string */ -struct cifs_ntsd { +struct smb_ntsd {__le16 revision;/* revision level */ __le16 type;__le32 osidoffset;
@@ -194,6 +194,6 @@ struct owner_group_sids {* Minimum security descriptor can be one without any SACL and DACL and can * consist of revision, type, and two sids of minimum size for owner and group */ -#define MIN_SEC_DESC_LEN (sizeof(struct cifs_ntsd) + (2 * MIN_SID_LEN)) +#define MIN_SEC_DESC_LEN (sizeof(struct smb_ntsd) + (2 * MIN_SID_LEN))#endif /* _CIFSACL_H */
fs/smb/client/cifsglob.h +6 -6
@@ -536,12 +536,12 @@ struct smb_version_operations {int (*set_EA)(const unsigned int ,struct cifs_tcon *,const char *,const char *,const void *,const __u16 ,const struct nls_table *,struct cifs_sb_info *); -struct cifs_ntsd * (*get_acl)(struct cifs_sb_info *,struct inode *, -const char *,u32 *,u32 ); -struct cifs_ntsd * (*get_acl_by_fid)(struct cifs_sb_info *, -const struct cifs_fid *,u32 *,u32 ); -int (*set_acl)(struct cifs_ntsd *,__u32 ,struct inode *,const char *, -int ); +struct smb_ntsd * (*get_acl)(struct cifs_sb_info *cifssb,struct inode *ino, +const char *patch,u32 *plen,u32 info); +struct smb_ntsd * (*get_acl_by_fid)(struct cifs_sb_info *cifssmb, +const struct cifs_fid *pfid,u32 *plen,u32 info); +int (*set_acl)(struct smb_ntsd *pntsd,__u32 len,struct inode *ino,const char *path, +int flag);/* writepages retry size */ unsigned int (*wp_retry_size)(struct inode *);/* get mtu credits */
fs/smb/client/cifsproto.h +8 -8
@@ -233,16 +233,16 @@ extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, const char *path, const struct cifs_fid *pfid);extern int id_mode_to_cifs_acl (struct inode *inode,const char *path,__u64 *pnmode,kuid_t uid,kgid_t gid); -extern struct cifs_ntsd *get_cifs_acl (struct cifs_sb_info *,struct inode *, -const char *,u32 *,u32 ); -extern struct cifs_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *, -const struct cifs_fid *,u32 *,u32 ); +extern struct smb_ntsd *get_cifs_acl (struct cifs_sb_info *cifssmb,struct inode *ino, +const char *path,u32 *plen,u32 info); +extern struct smb_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *cifssb, +const struct cifs_fid *pfid,u32 *plen,u32 info);extern struct posix_acl *cifs_get_acl (struct mnt_idmap *idmap,struct dentry *dentry,int type);extern int cifs_set_acl (struct mnt_idmap *idmap,struct dentry *dentry,struct posix_acl *acl,int type); -extern int set_cifs_acl (struct cifs_ntsd *,__u32 ,struct inode *, -const char *,int ); +extern int set_cifs_acl (struct smb_ntsd *pntsd,__u32 len,struct inode *ino, +const char *path,int flag);extern unsigned int setup_authusers_ACE (struct cifs_ace *pace);extern unsigned int setup_special_mode_ACE (struct cifs_ace *pace,__u64 nmode);extern unsigned int setup_special_user_owner_ACE (struct cifs_ace *pace);
@@ -570,9 +570,9 @@ extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,const struct nls_table *nls_codepage, struct cifs_sb_info *cifs_sb);extern int CIFSSMBGetCIFSACL (const unsigned int xid,struct cifs_tcon *tcon, -__u16 fid,struct cifs_ntsd **acl_inf,__u32 *buflen); +__u16 fid,struct smb_ntsd **acl_inf,__u32 *buflen);extern int CIFSSMBSetCIFSACL (const unsigned int ,struct cifs_tcon *,__u16 , -struct cifs_ntsd *,__u32 ,int ); +struct smb_ntsd *pntsd,__u32 len,int aclflag); extern int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon, const unsigned char *searchName, struct posix_acl **acl, const int acl_type,
fs/smb/client/cifssmb.c +3 -3
@@ -3428,7 +3428,7 @@ validate_ntransact(char *buf, char **ppparm, char **ppdata,/* Get Security Descriptor (by handle) from remote server for a file or dir */ int CIFSSMBGetCIFSACL (const unsigned int xid,struct cifs_tcon *tcon,__u16 fid, -struct cifs_ntsd **acl_inf,__u32 *pbuflen) +struct smb_ntsd **acl_inf,__u32 *pbuflen) {int rc =0 ;int buf_type =0 ;
@@ -3498,7 +3498,7 @@ CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid,/* check if buffer is big enough for the acl header followed by the smallest SID */ -if ((*pbuflen <sizeof (struct cifs_ntsd ) +8 ) || +if ((*pbuflen <sizeof (struct smb_ntsd ) +8 ) || (*pbuflen >=64 *1024 )) {cifs_dbg (VFS ,"bad acl length %d\n" , *pbuflen); rc = -EINVAL ;
@@ -3518,7 +3518,7 @@ CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid,int CIFSSMBSetCIFSACL (const unsigned int xid,struct cifs_tcon *tcon,__u16 fid, -struct cifs_ntsd *pntsd,__u32 acllen,int aclflag) +struct smb_ntsd *pntsd,__u32 acllen,int aclflag) {__u16 byte_count, param_count, data_count, param_offset, data_offset;int rc =0 ;
fs/smb/client/smb2ops.c +7 -7
@@ -3048,11 +3048,11 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,return rc; } -static struct cifs_ntsd * +static struct smb_ntsd *get_smb2_acl_by_fid (struct cifs_sb_info *cifs_sb,const struct cifs_fid *cifsfid,u32 *pacllen,u32 info) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;unsigned int xid;int rc = -EOPNOTSUPP ;struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);
@@ -3077,11 +3077,11 @@ get_smb2_acl_by_fid(struct cifs_sb_info *cifs_sb, } -static struct cifs_ntsd * +static struct smb_ntsd *get_smb2_acl_by_path (struct cifs_sb_info *cifs_sb,const char *path,u32 *pacllen,u32 info) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;u8 oplock =SMB2_OPLOCK_LEVEL_NONE ;unsigned int xid;int rc;
@@ -3144,7 +3144,7 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb, }static int -set_smb2_acl (struct cifs_ntsd *pnntsd,__u32 acllen, +set_smb2_acl (struct smb_ntsd *pnntsd,__u32 acllen,struct inode *inode,const char *path,int aclflag) {u8 oplock =SMB2_OPLOCK_LEVEL_NONE ;
@@ -3202,12 +3202,12 @@ set_smb2_acl(struct cifs_ntsd *pnntsd, __u32 acllen, }/* Retrieve an ACL from the server */ -static struct cifs_ntsd * +static struct smb_ntsd *get_smb2_acl (struct cifs_sb_info *cifs_sb,struct inode *inode,const char *path,u32 *pacllen,u32 info) { -struct cifs_ntsd *pntsd =NULL ; +struct smb_ntsd *pntsd =NULL ;struct cifsFileInfo *open_file =NULL ;if (inode && !(info &SACL_SECINFO ))
fs/smb/client/smb2pdu.c +1 -1
@@ -5683,7 +5683,7 @@ SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,int SMB2_set_acl (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid, -struct cifs_ntsd *pnntsd,int pacllen,int aclflag) +struct smb_ntsd *pnntsd,int pacllen,int aclflag) { return send_set_info(xid, tcon, persistent_fid, volatile_fid, current->tgid, 0, SMB2_O_INFO_SECURITY, aclflag,
fs/smb/client/smb2proto.h +1 -1
@@ -238,7 +238,7 @@ extern int SMB2_set_info_init(struct cifs_tcon *tcon,extern void SMB2_set_info_free (struct smb_rqst *rqst);extern int SMB2_set_acl (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid, -struct cifs_ntsd *pnntsd,int pacllen,int aclflag); +struct smb_ntsd *pnntsd,int pacllen,int aclflag);extern int SMB2_set_ea (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid,struct smb2_file_full_ea_info *buf,int len);
fs/smb/client/xattr.c +2 -2
@@ -162,7 +162,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler,case XATTR_CIFS_ACL :case XATTR_CIFS_NTSD :case XATTR_CIFS_NTSD_FULL : { -struct cifs_ntsd *pacl; +struct smb_ntsd *pacl;if (!value) goto out;
@@ -315,7 +315,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,* fetch owner and DACL otherwise */ u32 acllen, extra_info; -struct cifs_ntsd *pacl; +struct smb_ntsd *pacl;if (pTcon->ses->server->ops->get_acl ==NULL ) goto out;/* rc already EOPNOTSUPP */
Signature · 1 line
2.43.0
[email protected]
reviewerPATCH v2 7/12 smb/client: rename cifs_sid to smb_sid
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \
's/struct cifs_sid/struct smb_sid/g' {} +--- fs/smb/client/cifsacl.c | 96 +++++++++++++++++++-------------------- fs/smb/client/cifsacl.h | 6 +-- fs/smb/client/cifsglob.h | 8 ++-- fs/smb/client/cifsproto.h | 2 +- fs/smb/client/smb2inode.c | 4 +- fs/smb/client/smb2pdu.c | 2 +- fs/smb/client/smb2pdu.h | 8 ++-- 7 files changed, 63 insertions(+), 63 deletions(-)
fs/smb/client/cifsacl.c +48 -48
@@ -27,18 +27,18 @@#include "cifs_unicode.h" /* security id for everyone/world system group */ -static const struct cifs_sid sid_everyone = { +static const struct smb_sid sid_everyone = {1 ,1 , {0 ,0 ,0 ,0 ,0 ,1 }, {0 } };/* security id for Authenticated Users system group */ -static const struct cifs_sid sid_authusers = { +static const struct smb_sid sid_authusers = {1 ,1 , {0 ,0 ,0 ,0 ,0 ,5 }, {cpu_to_le32 (11 )} };/* S-1-22-1 Unmapped Unix users */ -static const struct cifs_sid sid_unix_users = {1 ,1 , {0 ,0 ,0 ,0 ,0 ,22 }, +static const struct smb_sid sid_unix_users = {1 ,1 , {0 ,0 ,0 ,0 ,0 ,22 }, {cpu_to_le32 (1 ),0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 } };/* S-1-22-2 Unmapped Unix groups */ -static const struct cifs_sid sid_unix_groups = {1 ,1 , {0 ,0 ,0 ,0 ,0 ,22 }, +static const struct smb_sid sid_unix_groups = {1 ,1 , {0 ,0 ,0 ,0 ,0 ,22 }, {cpu_to_le32 (2 ),0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 } };/*
@@ -48,17 +48,17 @@ static const struct cifs_sid sid_unix_groups = { 1, 1, {0, 0, 0, 0, 0, 22},/* S-1-5-88 MS NFS and Apple style UID/GID/mode */ /* S-1-5-88-1 Unix uid */ -static const struct cifs_sid sid_unix_NFS_users = {1 ,2 , {0 ,0 ,0 ,0 ,0 ,5 }, +static const struct smb_sid sid_unix_NFS_users = {1 ,2 , {0 ,0 ,0 ,0 ,0 ,5 }, {cpu_to_le32 (88 ),cpu_to_le32 (1 ),0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 } };/* S-1-5-88-2 Unix gid */ -static const struct cifs_sid sid_unix_NFS_groups = {1 ,2 , {0 ,0 ,0 ,0 ,0 ,5 }, +static const struct smb_sid sid_unix_NFS_groups = {1 ,2 , {0 ,0 ,0 ,0 ,0 ,5 }, {cpu_to_le32 (88 ),cpu_to_le32 (2 ),0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 } };/* S-1-5-88-3 Unix mode */ -static const struct cifs_sid sid_unix_NFS_mode = {1 ,2 , {0 ,0 ,0 ,0 ,0 ,5 }, +static const struct smb_sid sid_unix_NFS_mode = {1 ,2 , {0 ,0 ,0 ,0 ,0 ,5 }, {cpu_to_le32 (88 ),cpu_to_le32 (3 ),0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 } };
@@ -106,7 +106,7 @@ static struct key_type cifs_idmap_key_type = { };static char * -sid_to_key_str (struct cifs_sid *sidptr,unsigned int type) +sid_to_key_str (struct smb_sid *sidptr,unsigned int type) {int i, len;unsigned int saval;
@@ -158,7 +158,7 @@ sid_to_key_str(struct cifs_sid *sidptr, unsigned int type)* the same returns zero, if they do not match returns non-zero. */ static int -compare_sids (const struct cifs_sid *ctsid,const struct cifs_sid *cwsid) +compare_sids (const struct smb_sid *ctsid,const struct smb_sid *cwsid) {int i;int num_subauth, num_sat, num_saw;
@@ -204,11 +204,11 @@ compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) }static bool -is_well_known_sid (const struct cifs_sid *psid,uint32_t *puid,bool is_group) +is_well_known_sid (const struct smb_sid *psid,uint32_t *puid,bool is_group) {int i;int num_subauth; -const struct cifs_sid *pwell_known_sid; +const struct smb_sid *pwell_known_sid;if (!psid || (puid ==NULL ))return false;
@@ -260,7 +260,7 @@ is_well_known_sid(const struct cifs_sid *psid, uint32_t *puid, bool is_group) }static __u16 -cifs_copy_sid (struct cifs_sid *dst,const struct cifs_sid *src) +cifs_copy_sid (struct smb_sid *dst,const struct smb_sid *src) {int i;__u16 size =1 +1 +6 ;
@@ -277,11 +277,11 @@ cifs_copy_sid(struct cifs_sid *dst, const struct cifs_sid *src) }static int -id_to_sid (unsigned int cid,uint sidtype,struct cifs_sid *ssid) +id_to_sid (unsigned int cid,uint sidtype,struct smb_sid *ssid) {int rc;struct key *sidkey; -struct cifs_sid *ksid; +struct smb_sid *ksid;unsigned int ksid_size;char desc[3 +10 +1 ];/* 3 byte prefix + 10 bytes for value + NULL */ const struct cred *saved_cred;
@@ -312,8 +312,8 @@ id_to_sid(unsigned int cid, uint sidtype, struct cifs_sid *ssid)* it could be. */ ksid = sidkey->datalen <=sizeof (sidkey->payload) ? - (struct cifs_sid *)&sidkey->payload : - (struct cifs_sid *)sidkey->payload.data[0 ]; + (struct smb_sid *)&sidkey->payload : + (struct smb_sid *)sidkey->payload.data[0 ]; ksid_size =CIFS_SID_BASE_SIZE + (ksid->num_subauth *sizeof (__le32));if (ksid_size > sidkey->datalen) {
@@ -336,7 +336,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct cifs_sid *ssid) }int -sid_to_id (struct cifs_sb_info *cifs_sb,struct cifs_sid *psid, +sid_to_id (struct cifs_sb_info *cifs_sb,struct smb_sid *psid,struct cifs_fattr *fattr,uint sidtype) {int rc =0 ;
@@ -518,11 +518,11 @@ exit_cifs_idmap(void)static __u32 copy_sec_desc (const struct smb_ntsd *pntsd,struct smb_ntsd *pnntsd,__u32 sidsoffset, -struct cifs_sid *pownersid, -struct cifs_sid *pgrpsid) +struct smb_sid *pownersid, +struct smb_sid *pgrpsid) { -struct cifs_sid *owner_sid_ptr, *group_sid_ptr; -struct cifs_sid *nowner_sid_ptr, *ngroup_sid_ptr; +struct smb_sid *owner_sid_ptr, *group_sid_ptr; +struct smb_sid *nowner_sid_ptr, *ngroup_sid_ptr;/* copy security descriptor control portion */ pnntsd->revision = pntsd->revision;
@@ -530,28 +530,28 @@ static __u32 copy_sec_desc(const struct smb_ntsd *pntsd, pnntsd->dacloffset =cpu_to_le32 (sizeof (struct smb_ntsd )); pnntsd->sacloffset =0 ; pnntsd->osidoffset =cpu_to_le32 (sidsoffset); - pnntsd->gsidoffset =cpu_to_le32 (sidsoffset +sizeof (struct cifs_sid )); + pnntsd->gsidoffset =cpu_to_le32 (sidsoffset +sizeof (struct smb_sid ));/* copy owner sid */ if (pownersid) owner_sid_ptr = pownersid;else - owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + + owner_sid_ptr = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->osidoffset)); - nowner_sid_ptr = (struct cifs_sid *)((char *)pnntsd + sidsoffset); + nowner_sid_ptr = (struct smb_sid *)((char *)pnntsd + sidsoffset);cifs_copy_sid (nowner_sid_ptr, owner_sid_ptr);/* copy group sid */ if (pgrpsid) group_sid_ptr = pgrpsid;else - group_sid_ptr = (struct cifs_sid *)((char *)pntsd + + group_sid_ptr = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->gsidoffset)); - ngroup_sid_ptr = (struct cifs_sid *)((char *)pnntsd + sidsoffset + -sizeof (struct cifs_sid )); + ngroup_sid_ptr = (struct smb_sid *)((char *)pnntsd + sidsoffset + +sizeof (struct smb_sid ));cifs_copy_sid (ngroup_sid_ptr, group_sid_ptr); -return sidsoffset + (2 *sizeof (struct cifs_sid )); +return sidsoffset + (2 *sizeof (struct smb_sid )); }
@@ -666,7 +666,7 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,return ; } -static __u16 cifs_copy_ace (struct cifs_ace *dst,struct cifs_ace *src,struct cifs_sid *psid) +static __u16 cifs_copy_ace (struct cifs_ace *dst,struct cifs_ace *src,struct smb_sid *psid) {__u16 size =1 +1 +2 +4 ;
@@ -686,7 +686,7 @@ static __u16 cifs_copy_ace(struct cifs_ace *dst, struct cifs_ace *src, struct ci }static __u16 fill_ace_for_sid (struct cifs_ace *pntace, -const struct cifs_sid *psid,__u64 nmode, +const struct smb_sid *psid,__u64 nmode,umode_t bits,__u8 access_type,bool allow_delete_child) {
@@ -759,7 +759,7 @@ static void dump_ace(struct cifs_ace *pace, char *end_of_acl)#endif static void parse_dacl (struct cifs_acl *pdacl,char *end_of_acl, -struct cifs_sid *pownersid,struct cifs_sid *pgrpsid, +struct smb_sid *pownersid,struct smb_sid *pgrpsid,struct cifs_fattr *fattr,bool mode_from_special_sid) {int i;
@@ -930,8 +930,8 @@ unsigned int setup_special_user_owner_ACE(struct cifs_ace *pntace) }static void populate_new_aces (char *nacl_base, -struct cifs_sid *pownersid, -struct cifs_sid *pgrpsid, +struct smb_sid *pownersid, +struct smb_sid *pgrpsid,__u64 *pnmode,u32 *pnum_aces,u16 *pnsize,bool modefromsid) {
@@ -967,7 +967,7 @@ static void populate_new_aces(char *nacl_base,* updated in the inode. */ -if (!memcmp (pownersid, pgrpsid,sizeof (struct cifs_sid ))) { +if (!memcmp (pownersid, pgrpsid,sizeof (struct smb_sid ))) {/* * Case when owner and group SIDs are the same. * Set the more restrictive of the two modes.
@@ -1035,8 +1035,8 @@ static void populate_new_aces(char *nacl_base, }static __u16 replace_sids_and_copy_aces (struct cifs_acl *pdacl,struct cifs_acl *pndacl, -struct cifs_sid *pownersid,struct cifs_sid *pgrpsid, -struct cifs_sid *pnownersid,struct cifs_sid *pngrpsid) +struct smb_sid *pownersid,struct smb_sid *pgrpsid, +struct smb_sid *pnownersid,struct smb_sid *pngrpsid) {int i;u16 size =0 ;
@@ -1075,7 +1075,7 @@ static __u16 replace_sids_and_copy_aces(struct cifs_acl *pdacl, struct cifs_acl }static int set_chmod_dacl (struct cifs_acl *pdacl,struct cifs_acl *pndacl, -struct cifs_sid *pownersid,struct cifs_sid *pgrpsid, +struct smb_sid *pownersid,struct smb_sid *pgrpsid,__u64 *pnmode,bool mode_from_sid) {int i;
@@ -1156,7 +1156,7 @@ static int set_chmod_dacl(struct cifs_acl *pdacl, struct cifs_acl *pndacl,return 0 ; } -static int parse_sid (struct cifs_sid *psid,char *end_of_acl) +static int parse_sid (struct smb_sid *psid,char *end_of_acl) {/* BB need to add parm so we can store the SID BB */
@@ -1195,7 +1195,7 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb, bool get_mode_from_special_sid) {int rc =0 ; -struct cifs_sid *owner_sid_ptr, *group_sid_ptr; +struct smb_sid *owner_sid_ptr, *group_sid_ptr;struct cifs_acl *dacl_ptr;/* no need for SACL ptr */ char *end_of_acl = ((char *)pntsd) + acl_len;__u32 dacloffset;
@@ -1203,9 +1203,9 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb,if (pntsd ==NULL )return -EIO ; - owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + + owner_sid_ptr = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->osidoffset)); - group_sid_ptr = (struct cifs_sid *)((char *)pntsd + + group_sid_ptr = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->gsidoffset)); dacloffset =le32_to_cpu (pntsd->dacloffset); dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset);
@@ -1257,8 +1257,8 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,__u32 dacloffset;__u32 ndacloffset;__u32 sidsoffset; -struct cifs_sid *owner_sid_ptr, *group_sid_ptr; -struct cifs_sid *nowner_sid_ptr =NULL , *ngroup_sid_ptr =NULL ; +struct smb_sid *owner_sid_ptr, *group_sid_ptr; +struct smb_sid *nowner_sid_ptr =NULL , *ngroup_sid_ptr =NULL ;struct cifs_acl *dacl_ptr =NULL ;/* no need for SACL ptr */ struct cifs_acl *ndacl_ptr =NULL ;/* no need for SACL ptr */ char *end_of_acl = ((char *)pntsd) + secdesclen;
@@ -1273,9 +1273,9 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd, } } - owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + + owner_sid_ptr = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->osidoffset)); - group_sid_ptr = (struct cifs_sid *)((char *)pntsd + + group_sid_ptr = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->gsidoffset));if (pnmode && *pnmode !=NO_CHANGE_64 ) {/* chmod */
@@ -1305,7 +1305,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,if (uid_valid (uid)) {/* chown */ uid_t id; - nowner_sid_ptr =kzalloc (sizeof (struct cifs_sid ), + nowner_sid_ptr =kzalloc (sizeof (struct smb_sid ),GFP_KERNEL );if (!nowner_sid_ptr) { rc = -ENOMEM ;
@@ -1334,7 +1334,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd, }if (gid_valid (gid)) {/* chgrp */ gid_t id; - ngroup_sid_ptr =kzalloc (sizeof (struct cifs_sid ), + ngroup_sid_ptr =kzalloc (sizeof (struct smb_sid ),GFP_KERNEL );if (!ngroup_sid_ptr) { rc = -ENOMEM ;
@@ -1630,7 +1630,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, nsecdesclen +=5 *sizeof (struct cifs_ace ); }else {/* chown */ /* When ownership changes, changes new owner sid length could be different */ - nsecdesclen =sizeof (struct smb_ntsd ) + (sizeof (struct cifs_sid ) *2 ); + nsecdesclen =sizeof (struct smb_ntsd ) + (sizeof (struct smb_sid ) *2 ); dacloffset =le32_to_cpu (pntsd->dacloffset);if (dacloffset) { dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset);
fs/smb/client/cifsacl.h +3 -3
@@ -64,14 +64,14 @@ struct smb_ntsd {__le32 dacloffset; } __attribute__((packed)); -struct cifs_sid { +struct smb_sid {__u8 revision;/* revision level */ __u8 num_subauth;__u8 authority[NUM_AUTHS ];__le32 sub_auth[SID_MAX_SUB_AUTHORITIES ];/* sub_auth[num_subauth] */ } __attribute__((packed)); -/* size of a struct cifs_sid, sans sub_auth array */ +/* size of a struct smb_sid, sans sub_auth array */ #define CIFS_SID_BASE_SIZE (1 + 1 + NUM_AUTHS)struct cifs_acl {
@@ -116,7 +116,7 @@ struct cifs_ace {__u8 flags;__le16 size;__le32 access_req; -struct cifs_sid sid;/* ie UUID of user or group who gets these perms */ +struct smb_sid sid;/* ie UUID of user or group who gets these perms */ } __attribute__((packed));/*
fs/smb/client/cifsglob.h +4 -4
@@ -202,8 +202,8 @@ struct cifs_cred {int gid;int mode;int cecount; -struct cifs_sid osid; -struct cifs_sid gsid; +struct smb_sid osid; +struct smb_sid gsid;struct cifs_ntace *ntaces;struct cifs_ace *aces; };
@@ -231,8 +231,8 @@ struct cifs_open_info_data {unsigned int eas_len; } wsl;char *symlink_target; -struct cifs_sid posix_owner; -struct cifs_sid posix_group; +struct smb_sid posix_owner; +struct smb_sid posix_group;union {struct smb2_file_all_info fi;struct smb311_posix_qinfo posix_fi;
fs/smb/client/cifsproto.h +1 -1
@@ -225,7 +225,7 @@ extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs,extern int cifs_rename_pending_delete (const char *full_path,struct dentry *dentry,const unsigned int xid); -extern int sid_to_id (struct cifs_sb_info *cifs_sb,struct cifs_sid *psid, +extern int sid_to_id (struct cifs_sb_info *cifs_sb,struct smb_sid *psid,struct cifs_fattr *fattr,uint sidtype); extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, struct inode *inode,
fs/smb/client/smb2inode.c +2 -2
@@ -315,7 +315,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,SMB2_O_INFO_FILE ,0 ,sizeof (struct smb311_posix_qinfo *) + (PATH_MAX *2 ) + - (sizeof(struct cifs_sid) * 2), 0, NULL); + (sizeof(struct smb_sid) * 2), 0, NULL); }else { rc = SMB2_query_info_init(tcon, server, &rqst[num_rqst],
@@ -325,7 +325,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,SMB2_O_INFO_FILE ,0 ,sizeof (struct smb311_posix_qinfo *) + (PATH_MAX *2 ) + - (sizeof(struct cifs_sid) * 2), 0, NULL); + (sizeof(struct smb_sid) * 2), 0, NULL); }if (!rc && (!cfile || num_rqst >1 )) {smb2_set_next_command (tcon, &rqst[num_rqst]);
fs/smb/client/smb2pdu.c +1 -1
@@ -3906,7 +3906,7 @@ SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, struct smb311_posix_qinfo *data, u32 *plen) { size_t output_len = sizeof(struct smb311_posix_qinfo *) + - (sizeof (struct cifs_sid ) *2 ) + (PATH_MAX *2 ); + (sizeof (struct smb_sid ) *2 ) + (PATH_MAX *2 ); *plen =0 ; return query_info(xid, tcon, persistent_fid, volatile_fid,
fs/smb/client/smb2pdu.h +4 -4
@@ -364,8 +364,8 @@ struct create_posix_rsp {u32 nlink;u32 reparse_tag;u32 mode; -struct cifs_sid owner;/* var-sized on the wire */ -struct cifs_sid group;/* var-sized on the wire */ +struct smb_sid owner;/* var-sized on the wire */ +struct smb_sid group;/* var-sized on the wire */ } __packed;#define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
@@ -408,8 +408,8 @@ struct smb2_posix_info {struct smb2_posix_info_parsed {const struct smb2_posix_info *base;size_t size; -struct cifs_sid owner; -struct cifs_sid group; +struct smb_sid owner; +struct smb_sid group;int name_len;const u8 *name; };
Signature · 1 line
2.34.1
Re: [PATCH v2 07/12] smb/client: rename cifs_sid to smb_sid
Quoted 11 lines · On Thu, Aug 22, 2024 at 5:23 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \ 's/struct cifs_sid/struct smb_sid/g' {} +Signed-off-by ChenXiaoSong <[email protected]>
Looks good to me.
Thanks!
[email protected]
reviewerPATCH v2 8/12 smb/client: rename cifs_acl to smb_acl
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \
's/struct cifs_acl/struct smb_acl/g' {} +--- fs/smb/client/cifsacl.c | 34 +++++++++++++++++----------------- fs/smb/client/cifsacl.h | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-)
fs/smb/client/cifsacl.c +17 -17
@@ -758,7 +758,7 @@ static void dump_ace(struct cifs_ace *pace, char *end_of_acl) }#endif -static void parse_dacl (struct cifs_acl *pdacl,char *end_of_acl, +static void parse_dacl (struct smb_acl *pdacl,char *end_of_acl,struct smb_sid *pownersid,struct smb_sid *pgrpsid,struct cifs_fattr *fattr,bool mode_from_special_sid) {
@@ -793,7 +793,7 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, fattr->cf_mode &= ~(0777 ); acl_base = (char *)pdacl; - acl_size =sizeof (struct cifs_acl ); + acl_size =sizeof (struct smb_acl ); num_aces =le32_to_cpu (pdacl->num_aces);if (num_aces >0 ) {
@@ -1034,7 +1034,7 @@ static void populate_new_aces(char *nacl_base, *pnsize = nsize; } -static __u16 replace_sids_and_copy_aces (struct cifs_acl *pdacl,struct cifs_acl *pndacl, +static __u16 replace_sids_and_copy_aces (struct smb_acl *pdacl,struct smb_acl *pndacl,struct smb_sid *pownersid,struct smb_sid *pgrpsid,struct smb_sid *pnownersid,struct smb_sid *pngrpsid) {
@@ -1049,11 +1049,11 @@ static __u16 replace_sids_and_copy_aces(struct cifs_acl *pdacl, struct cifs_aclu16 ace_size =0 ; acl_base = (char *)pdacl; - size =sizeof (struct cifs_acl ); + size =sizeof (struct smb_acl ); src_num_aces =le32_to_cpu (pdacl->num_aces); nacl_base = (char *)pndacl; - nsize =sizeof (struct cifs_acl ); + nsize =sizeof (struct smb_acl );/* Go through all the ACEs */ for (i =0 ; i < src_num_aces; ++i) {
@@ -1074,7 +1074,7 @@ static __u16 replace_sids_and_copy_aces(struct cifs_acl *pdacl, struct cifs_aclreturn nsize; } -static int set_chmod_dacl (struct cifs_acl *pdacl,struct cifs_acl *pndacl, +static int set_chmod_dacl (struct smb_acl *pdacl,struct smb_acl *pndacl,struct smb_sid *pownersid,struct smb_sid *pgrpsid,__u64 *pnmode,bool mode_from_sid) {
@@ -1091,7 +1091,7 @@ static int set_chmod_dacl(struct cifs_acl *pdacl, struct cifs_acl *pndacl,/* Assuming that pndacl and pnmode are never NULL */ nacl_base = (char *)pndacl; - nsize =sizeof (struct cifs_acl ); + nsize =sizeof (struct smb_acl );/* If pdacl is NULL, we don't have a src. Simply populate new ACL. */ if (!pdacl) {
@@ -1103,7 +1103,7 @@ static int set_chmod_dacl(struct cifs_acl *pdacl, struct cifs_acl *pndacl, } acl_base = (char *)pdacl; - size =sizeof (struct cifs_acl ); + size =sizeof (struct smb_acl ); src_num_aces =le32_to_cpu (pdacl->num_aces);/* Retain old ACEs which we can retain */
@@ -1196,7 +1196,7 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb, {int rc =0 ;struct smb_sid *owner_sid_ptr, *group_sid_ptr; -struct cifs_acl *dacl_ptr;/* no need for SACL ptr */ +struct smb_acl *dacl_ptr;/* no need for SACL ptr */ char *end_of_acl = ((char *)pntsd) + acl_len;__u32 dacloffset;
@@ -1208,7 +1208,7 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb, group_sid_ptr = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->gsidoffset)); dacloffset =le32_to_cpu (pntsd->dacloffset); - dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset); + dacl_ptr = (struct smb_acl *)((char *)pntsd + dacloffset); cifs_dbg(NOISY, "revision %d type 0x%x ooffset 0x%x goffset 0x%x sacloffset 0x%x dacloffset 0x%x\n", pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset), le32_to_cpu(pntsd->gsidoffset),
@@ -1259,14 +1259,14 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,__u32 sidsoffset;struct smb_sid *owner_sid_ptr, *group_sid_ptr;struct smb_sid *nowner_sid_ptr =NULL , *ngroup_sid_ptr =NULL ; -struct cifs_acl *dacl_ptr =NULL ;/* no need for SACL ptr */ -struct cifs_acl *ndacl_ptr =NULL ;/* no need for SACL ptr */ +struct smb_acl *dacl_ptr =NULL ;/* no need for SACL ptr */ +struct smb_acl *ndacl_ptr =NULL ;/* no need for SACL ptr */ char *end_of_acl = ((char *)pntsd) + secdesclen;u16 size =0 ; dacloffset =le32_to_cpu (pntsd->dacloffset);if (dacloffset) { - dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset); + dacl_ptr = (struct smb_acl *)((char *)pntsd + dacloffset);if (end_of_acl < (char *)dacl_ptr +le16_to_cpu (dacl_ptr->size)) {cifs_dbg (VFS ,"Server returned illegal ACL size\n" );return -EINVAL ;
@@ -1280,7 +1280,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,if (pnmode && *pnmode !=NO_CHANGE_64 ) {/* chmod */ ndacloffset =sizeof (struct smb_ntsd ); - ndacl_ptr = (struct cifs_acl *)((char *)pnntsd + ndacloffset); + ndacl_ptr = (struct smb_acl *)((char *)pnntsd + ndacloffset); ndacl_ptr->revision = dacloffset ? dacl_ptr->revision :cpu_to_le16 (ACL_REVISION );
@@ -1298,7 +1298,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd, *aclflag |=CIFS_ACL_DACL ; }else { ndacloffset =sizeof (struct smb_ntsd ); - ndacl_ptr = (struct cifs_acl *)((char *)pnntsd + ndacloffset); + ndacl_ptr = (struct smb_acl *)((char *)pnntsd + ndacloffset); ndacl_ptr->revision = dacloffset ? dacl_ptr->revision :cpu_to_le16 (ACL_REVISION ); ndacl_ptr->num_aces = dacl_ptr ? dacl_ptr->num_aces :0 ;
@@ -1580,7 +1580,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,__u32 secdesclen =0 ;__u32 nsecdesclen =0 ;__u32 dacloffset =0 ; -struct cifs_acl *dacl_ptr =NULL ; +struct smb_acl *dacl_ptr =NULL ;struct smb_ntsd *pntsd =NULL ;/* acl obtained from server */ struct smb_ntsd *pnntsd =NULL ;/* modified acl to be sent to server */ struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);
@@ -1633,7 +1633,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, nsecdesclen =sizeof (struct smb_ntsd ) + (sizeof (struct smb_sid ) *2 ); dacloffset =le32_to_cpu (pntsd->dacloffset);if (dacloffset) { - dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset); + dacl_ptr = (struct smb_acl *)((char *)pntsd + dacloffset);if (mode_from_sid) nsecdesclen +=le32_to_cpu (dacl_ptr->num_aces) *sizeof (struct cifs_ace );
fs/smb/client/cifsacl.h +2 -2
@@ -34,7 +34,7 @@* owner, group and world). */ #define DEFAULT_SEC_DESC_LEN (sizeof(struct smb_ntsd) + \ - sizeof(struct cifs_acl) + \ + sizeof(struct smb_acl) + \ (sizeof(struct cifs_ace) * 4))/*
@@ -74,7 +74,7 @@ struct smb_sid {/* size of a struct smb_sid, sans sub_auth array */ #define CIFS_SID_BASE_SIZE (1 + 1 + NUM_AUTHS) -struct cifs_acl { +struct smb_acl {__le16 revision;/* revision level */ __le16 size;__le32 num_aces;
Signature · 1 line
2.34.1
Re: [PATCH v2 08/12] smb/client: rename cifs_acl to smb_acl
Quoted 11 lines · On Thu, Aug 22, 2024 at 5:23 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \ 's/struct cifs_acl/struct smb_acl/g' {} +Signed-off-by ChenXiaoSong <[email protected]>
Looks good to me.
Thanks.
[email protected]
reviewerPATCH v2 9/12 smb/client: rename cifs_ace to smb_ace
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \
's/struct cifs_ace/struct smb_ace/g' {} +--- fs/smb/client/cifsacl.c | 62 +++++++++++++++++++-------------------- fs/smb/client/cifsacl.h | 4 +-- fs/smb/client/cifsglob.h | 2 +- fs/smb/client/cifsproto.h | 6 ++-- fs/smb/client/smb2pdu.c | 8 ++--- 5 files changed, 41 insertions(+), 41 deletions(-)
fs/smb/client/cifsacl.c +31 -31
@@ -666,7 +666,7 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,return ; } -static __u16 cifs_copy_ace (struct cifs_ace *dst,struct cifs_ace *src,struct smb_sid *psid) +static __u16 cifs_copy_ace (struct smb_ace *dst,struct smb_ace *src,struct smb_sid *psid) {__u16 size =1 +1 +2 +4 ;
@@ -685,7 +685,7 @@ static __u16 cifs_copy_ace(struct cifs_ace *dst, struct cifs_ace *src, struct smreturn size; } -static __u16 fill_ace_for_sid (struct cifs_ace *pntace, +static __u16 fill_ace_for_sid (struct smb_ace *pntace,const struct smb_sid *psid,__u64 nmode,umode_t bits,__u8 access_type,bool allow_delete_child)
@@ -723,7 +723,7 @@ static __u16 fill_ace_for_sid(struct cifs_ace *pntace,#ifdef CONFIG_CIFS_DEBUG2 -static void dump_ace (struct cifs_ace *pace,char *end_of_acl) +static void dump_ace (struct smb_ace *pace,char *end_of_acl) {int num_subauth;
@@ -766,7 +766,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,int num_aces =0 ;int acl_size;char *acl_base; -struct cifs_ace **ppace; +struct smb_ace **ppace;/* BB need to add parm so we can store the SID BB */
@@ -799,15 +799,15 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,if (num_aces >0 ) {umode_t denied_mode =0 ; -if (num_aces >ULONG_MAX /sizeof (struct cifs_ace *)) +if (num_aces >ULONG_MAX /sizeof (struct smb_ace *))return ; - ppace =kmalloc_array (num_aces,sizeof (struct cifs_ace *), + ppace =kmalloc_array (num_aces,sizeof (struct smb_ace *),GFP_KERNEL );if (!ppace)return ;for (i =0 ; i < num_aces; ++i) { - ppace[i] = (struct cifs_ace *) (acl_base + acl_size); + ppace[i] = (struct smb_ace *) (acl_base + acl_size);#ifdef CONFIG_CIFS_DEBUG2 dump_ace (ppace[i], end_of_acl);#endif
@@ -849,7 +849,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,/* memcpy((void *)(&(cifscred->aces[i])), (void *)ppace[i], -sizeof(struct cifs_ace)); */ +sizeof(struct smb_ace)); */ acl_base = (char *)ppace[i]; acl_size =le16_to_cpu (ppace[i]->size);
@@ -861,7 +861,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,return ; } -unsigned int setup_authusers_ACE (struct cifs_ace *pntace) +unsigned int setup_authusers_ACE (struct smb_ace *pntace) {int i;unsigned int ace_size =20 ;
@@ -885,7 +885,7 @@ unsigned int setup_authusers_ACE(struct cifs_ace *pntace)* Fill in the special SID based on the mode. See * https://technet.microsoft.com/en-us/library/hh509017(v=ws.10).aspx */ -unsigned int setup_special_mode_ACE (struct cifs_ace *pntace,__u64 nmode) +unsigned int setup_special_mode_ACE (struct smb_ace *pntace,__u64 nmode) {int i;unsigned int ace_size =28 ;
@@ -907,7 +907,7 @@ unsigned int setup_special_mode_ACE(struct cifs_ace *pntace, __u64 nmode)return ace_size; } -unsigned int setup_special_user_owner_ACE (struct cifs_ace *pntace) +unsigned int setup_special_user_owner_ACE (struct smb_ace *pntace) {int i;unsigned int ace_size =28 ;
@@ -944,17 +944,17 @@ static void populate_new_aces(char *nacl_base,__u64 deny_user_mode =0 ;__u64 deny_group_mode =0 ;bool sticky_set = false; -struct cifs_ace *pnntace =NULL ; +struct smb_ace *pnntace =NULL ; nmode = *pnmode; num_aces = *pnum_aces; nsize = *pnsize;if (modefromsid) { - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pnntace = (struct smb_ace *) (nacl_base + nsize); nsize +=setup_special_mode_ACE (pnntace, nmode); num_aces++; - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pnntace = (struct smb_ace *) (nacl_base + nsize); nsize +=setup_authusers_ACE (pnntace); num_aces++; goto set_size;
@@ -992,7 +992,7 @@ static void populate_new_aces(char *nacl_base, sticky_set = true;if (deny_user_mode) { - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pnntace = (struct smb_ace *) (nacl_base + nsize); nsize +=fill_ace_for_sid (pnntace, pownersid, deny_user_mode,0700 ,ACCESS_DENIED , false); num_aces++;
@@ -1000,31 +1000,31 @@ static void populate_new_aces(char *nacl_base,/* Group DENY ACE does not conflict with owner ALLOW ACE. Keep in preferred order*/ if (deny_group_mode && !(deny_group_mode & (user_mode >>3 ))) { - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pnntace = (struct smb_ace *) (nacl_base + nsize); nsize +=fill_ace_for_sid (pnntace, pgrpsid, deny_group_mode,0070 ,ACCESS_DENIED , false); num_aces++; } - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pnntace = (struct smb_ace *) (nacl_base + nsize); nsize +=fill_ace_for_sid (pnntace, pownersid, user_mode,0700 ,ACCESS_ALLOWED , true); num_aces++;/* Group DENY ACE conflicts with owner ALLOW ACE. So keep it after. */ if (deny_group_mode && (deny_group_mode & (user_mode >>3 ))) { - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pnntace = (struct smb_ace *) (nacl_base + nsize); nsize +=fill_ace_for_sid (pnntace, pgrpsid, deny_group_mode,0070 ,ACCESS_DENIED , false); num_aces++; } - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pnntace = (struct smb_ace *) (nacl_base + nsize); nsize +=fill_ace_for_sid (pnntace, pgrpsid, group_mode,0070 ,ACCESS_ALLOWED , !sticky_set); num_aces++; - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pnntace = (struct smb_ace *) (nacl_base + nsize); nsize +=fill_ace_for_sid (pnntace, &sid_everyone, other_mode,0007 ,ACCESS_ALLOWED , !sticky_set); num_aces++;
@@ -1040,11 +1040,11 @@ static __u16 replace_sids_and_copy_aces(struct smb_acl *pdacl, struct smb_acl *p {int i;u16 size =0 ; -struct cifs_ace *pntace =NULL ; +struct smb_ace *pntace =NULL ;char *acl_base =NULL ;u32 src_num_aces =0 ;u16 nsize =0 ; -struct cifs_ace *pnntace =NULL ; +struct smb_ace *pnntace =NULL ;char *nacl_base =NULL ;u16 ace_size =0 ;
@@ -1057,8 +1057,8 @@ static __u16 replace_sids_and_copy_aces(struct smb_acl *pdacl, struct smb_acl *p/* Go through all the ACEs */ for (i =0 ; i < src_num_aces; ++i) { - pntace = (struct cifs_ace *) (acl_base + size); - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pntace = (struct smb_ace *) (acl_base + size); + pnntace = (struct smb_ace *) (nacl_base + nsize);if (pnownersid &&compare_sids (&pntace->sid, pownersid) ==0 ) ace_size =cifs_copy_ace (pnntace, pntace, pnownersid);
@@ -1080,11 +1080,11 @@ static int set_chmod_dacl(struct smb_acl *pdacl, struct smb_acl *pndacl, {int i;u16 size =0 ; -struct cifs_ace *pntace =NULL ; +struct smb_ace *pntace =NULL ;char *acl_base =NULL ;u32 src_num_aces =0 ;u16 nsize =0 ; -struct cifs_ace *pnntace =NULL ; +struct smb_ace *pnntace =NULL ;char *nacl_base =NULL ;u32 num_aces =0 ;bool new_aces_set = false;
@@ -1108,7 +1108,7 @@ static int set_chmod_dacl(struct smb_acl *pdacl, struct smb_acl *pndacl,/* Retain old ACEs which we can retain */ for (i =0 ; i < src_num_aces; ++i) { - pntace = (struct cifs_ace *) (acl_base + size); + pntace = (struct smb_ace *) (acl_base + size);if (!new_aces_set && (pntace->flags &INHERITED_ACE )) {/* Place the new ACEs in between existing explicit and inherited */
@@ -1130,7 +1130,7 @@ static int set_chmod_dacl(struct smb_acl *pdacl, struct smb_acl *pndacl, }/* update the pointer to the next ACE to populate*/ - pnntace = (struct cifs_ace *) (nacl_base + nsize); + pnntace = (struct smb_ace *) (nacl_base + nsize); nsize +=cifs_copy_ace (pnntace, pntace,NULL ); num_aces++;
@@ -1625,9 +1625,9 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, nsecdesclen = secdesclen;if (pnmode && *pnmode !=NO_CHANGE_64 ) {/* chmod */ if (mode_from_sid) - nsecdesclen +=2 *sizeof (struct cifs_ace ); + nsecdesclen +=2 *sizeof (struct smb_ace );else /* cifsacl */ - nsecdesclen +=5 *sizeof (struct cifs_ace ); + nsecdesclen +=5 *sizeof (struct smb_ace ); }else {/* chown */ /* When ownership changes, changes new owner sid length could be different */ nsecdesclen =sizeof (struct smb_ntsd ) + (sizeof (struct smb_sid ) *2 );
@@ -1636,7 +1636,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, dacl_ptr = (struct smb_acl *)((char *)pntsd + dacloffset);if (mode_from_sid) nsecdesclen += -le32_to_cpu (dacl_ptr->num_aces) *sizeof (struct cifs_ace ); +le32_to_cpu (dacl_ptr->num_aces) *sizeof (struct smb_ace );else /* cifsacl */ nsecdesclen +=le16_to_cpu (dacl_ptr->size); }
fs/smb/client/cifsacl.h +2 -2
@@ -35,7 +35,7 @@*/ #define DEFAULT_SEC_DESC_LEN (sizeof(struct smb_ntsd) + \ sizeof(struct smb_acl) + \ - (sizeof(struct cifs_ace) * 4)) + (sizeof(struct smb_ace) * 4))/* * Maximum size of a string representation of a SID:
@@ -111,7 +111,7 @@ struct smb_acl {#define SUCCESSFUL_ACCESS_ACE_FLAG 0x40#define FAILED_ACCESS_ACE_FLAG 0x80 -struct cifs_ace { +struct smb_ace {__u8 type;/* see above and MS-DTYP 2.4.4.1 */ __u8 flags;__le16 size;
fs/smb/client/cifsglob.h +1 -1
@@ -205,7 +205,7 @@ struct cifs_cred {struct smb_sid osid;struct smb_sid gsid;struct cifs_ntace *ntaces; -struct cifs_ace *aces; +struct smb_ace *aces; };struct cifs_open_info_data {
fs/smb/client/cifsproto.h +3 -3
@@ -243,9 +243,9 @@ extern int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, struct posix_acl *acl, int type);extern int set_cifs_acl (struct smb_ntsd *,__u32 ,struct inode *,const char *,int ); -extern unsigned int setup_authusers_ACE (struct cifs_ace *pace); -extern unsigned int setup_special_mode_ACE (struct cifs_ace *pace,__u64 nmode); -extern unsigned int setup_special_user_owner_ACE (struct cifs_ace *pace); +extern unsigned int setup_authusers_ACE (struct smb_ace *pace); +extern unsigned int setup_special_mode_ACE (struct smb_ace *pace,__u64 nmode); +extern unsigned int setup_special_user_owner_ACE (struct smb_ace *pace);extern void dequeue_mid (struct mid_q_entry *mid,bool malformed); extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
fs/smb/client/smb2pdu.c +4 -4
@@ -2623,7 +2623,7 @@ create_sd_buf(umode_t mode, bool set_owner, unsigned int *len)unsigned int group_offset =0 ;struct smb3_acl acl = {}; - *len =round_up (sizeof (struct crt_sd_ctxt ) + (sizeof (struct cifs_ace ) *4 ),8 ); + *len =round_up (sizeof (struct crt_sd_ctxt ) + (sizeof (struct smb_ace ) *4 ),8 );if (set_owner) {/* sizeof(struct owner_group_sids) is already multiple of 8 so no need to round */
@@ -2672,21 +2672,21 @@ create_sd_buf(umode_t mode, bool set_owner, unsigned int *len) ptr +=sizeof (struct smb3_acl );/* create one ACE to hold the mode embedded in reserved special SID */ - acelen =setup_special_mode_ACE ((struct cifs_ace *)ptr, (__u64 )mode); + acelen =setup_special_mode_ACE ((struct smb_ace *)ptr, (__u64 )mode); ptr += acelen; acl_size = acelen +sizeof (struct smb3_acl ); ace_count =1 ;if (set_owner) {/* we do not need to reallocate buffer to add the two more ACEs. plenty of space */ - acelen =setup_special_user_owner_ACE ((struct cifs_ace *)ptr); + acelen =setup_special_user_owner_ACE ((struct smb_ace *)ptr); ptr += acelen; acl_size += acelen; ace_count +=1 ; }/* and one more ACE to allow access for authenticated users */ - acelen =setup_authusers_ACE ((struct cifs_ace *)ptr); + acelen =setup_authusers_ACE ((struct smb_ace *)ptr); ptr += acelen; acl_size += acelen; ace_count +=1 ;
Signature · 1 line
2.34.1
Re: [PATCH v2 09/12] smb/client: rename cifs_ace to smb_ace
Quoted 11 lines · On Thu, Aug 22, 2024 at 5:23 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Preparation for moving acl definitions to new common header file.
Use the following shell command to rename:
find fs/smb/client -type f -exec sed -i \ 's/struct cifs_ace/struct smb_ace/g' {} +Signed-off-by ChenXiaoSong <[email protected]>
Looks good to me.
Thanks.
[email protected]
reviewerPATCH v2 10/12 smb: move some duplicate definitions to common/smbacl.h
In reply to [email protected]From: ChenXiaoSong <[email protected]>
In order to maintain the code more easily, move duplicate definitions to new common header file.
--- fs/smb/client/cifsacl.h | 91 +----------------------------- fs/smb/common/smbacl.h | 121 ++++++++++++++++++++++++++++++++++++++++ fs/smb/server/smbacl.h | 111 +----------------------------------- 3 files changed, 123 insertions(+), 200 deletions(-) create mode 100644 fs/smb/common/smbacl.h
fs/smb/client/cifsacl.h +1 -90
@@ -9,8 +9,7 @@#ifndef _CIFSACL_H#define _CIFSACL_H -#define NUM_AUTHS (6)/* number of authority fields */ -#define SID_MAX_SUB_AUTHORITIES (15)/* max number of sub authority fields */ +#include "../common/smbacl.h" #define READ_BIT 0x4#define WRITE_BIT 0x2
@@ -23,12 +22,6 @@#define UBITSHIFT 6#define GBITSHIFT 3 -#define ACCESS_ALLOWED 0 -#define ACCESS_DENIED 1 - -#define SIDOWNER 1 -#define SIDGROUP 2 -/* * Security Descriptor length containing DACL with 3 ACEs (one each for * owner, group and world).
@@ -37,88 +30,6 @@sizeof (struct smb_acl ) + \ (sizeof(struct smb_ace) * 4)) -/* -* Maximum size of a string representation of a SID: -* -* The fields are unsigned values in decimal. So: -* -* u8: max 3 bytes in decimal -* u32: max 10 bytes in decimal -* -* "S-" + 3 bytes for version field + 15 for authority field + NULL terminator -* -* For authority field, max is when all 6 values are non-zero and it must be -* represented in hex. So "-0x" + 12 hex digits. -* -* Add 11 bytes for each subauthority field (10 bytes each + 1 for '-') -*/ -#define SID_STRING_BASE_SIZE (2 + 3 + 15 + 1) -#define SID_STRING_SUBAUTH_SIZE (11)/* size of a single subauth string */ - -struct smb_ntsd { -__le16 revision;/* revision level */ -__le16 type; -__le32 osidoffset; -__le32 gsidoffset; -__le32 sacloffset; -__le32 dacloffset; -} __attribute__((packed)); - -struct smb_sid { -__u8 revision;/* revision level */ -__u8 num_subauth; -__u8 authority[NUM_AUTHS ]; -__le32 sub_auth[SID_MAX_SUB_AUTHORITIES ];/* sub_auth[num_subauth] */ -} __attribute__((packed)); - -/* size of a struct smb_sid, sans sub_auth array */ -#define CIFS_SID_BASE_SIZE (1 + 1 + NUM_AUTHS) - -struct smb_acl { -__le16 revision;/* revision level */ -__le16 size; -__le32 num_aces; -} __attribute__((packed)); - -/* ACE types - see MS-DTYP 2.4.4.1 */ -#define ACCESS_ALLOWED_ACE_TYPE 0x00 -#define ACCESS_DENIED_ACE_TYPE 0x01 -#define SYSTEM_AUDIT_ACE_TYPE 0x02 -#define SYSTEM_ALARM_ACE_TYPE 0x03 -#define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x04 -#define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05 -#define ACCESS_DENIED_OBJECT_ACE_TYPE 0x06 -#define SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07 -#define SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08 -#define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x09 -#define ACCESS_DENIED_CALLBACK_ACE_TYPE 0x0A -#define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0x0B -#define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0x0C -#define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0x0D -#define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0x0E/* Reserved */ -#define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0x0F -#define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10/* reserved */ -#define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11 -#define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12 -#define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13 - -/* ACE flags */ -#define OBJECT_INHERIT_ACE 0x01 -#define CONTAINER_INHERIT_ACE 0x02 -#define NO_PROPAGATE_INHERIT_ACE 0x04 -#define INHERIT_ONLY_ACE 0x08 -#define INHERITED_ACE 0x10 -#define SUCCESSFUL_ACCESS_ACE_FLAG 0x40 -#define FAILED_ACCESS_ACE_FLAG 0x80 - -struct smb_ace { -__u8 type;/* see above and MS-DTYP 2.4.4.1 */ -__u8 flags; -__le16 size; -__le32 access_req; -struct smb_sid sid;/* ie UUID of user or group who gets these perms */ -} __attribute__((packed)); -/* * The current SMB3 form of security descriptor is similar to what was used for * cifs (see above) but some fields are split, and fields in the struct below
fs/smb/common/smbacl.h new file +121 -0
121 lines not on this page · raw message
fs/smb/server/smbacl.h +1 -110
131 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
reviewerPATCH v2 11/12 smb: move SMB2 Status code to common header file
In reply to [email protected]From: ChenXiaoSong <[email protected]>
There are only 4 different definitions between the client and server:
- STATUS_SERVER_UNAVAILABLE: from client/smb2status.h
- STATUS_FILE_NOT_AVAILABLE: from client/smb2status.h
- STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP: from server/smbstatus.h
- STATUS_INVALID_LOCK_RANGE: from server/smbstatus.h
Rename client/smb2status.h to common/smb2status.h, and merge the 2 different definitions of server to common header file.
---
fs/smb/client/smb2file.c | 2 +-
fs/smb/client/smb2inode.c | 2 +-
fs/smb/client/smb2maperror.c | 2 +-
fs/smb/client/smb2misc.c | 2 +-
fs/smb/client/smb2ops.c | 2 +-
fs/smb/client/smb2pdu.c | 2 +-
fs/smb/client/smb2transport.c | 2 +-
fs/smb/{client => common}/smb2status.h | 2 +
fs/smb/server/oplock.c | 2 +-
fs/smb/server/server.c | 2 +-
fs/smb/server/smb2misc.c | 2 +-
fs/smb/server/smb2pdu.c | 2 +-
fs/smb/server/smb_common.c | 2 +-
fs/smb/server/smbstatus.h | 1822 ------------------------
fs/smb/server/transport_rdma.c | 2 +-
15 files changed, 15 insertions(+), 1835 deletions(-)
rename fs/smb/{client => common}/smb2status.h (99%)
delete mode 100644 fs/smb/server/smbstatus.hfs/smb/client/smb2file.c +1 -1
@@ -21,7 +21,7 @@#include "cifs_unicode.h" #include "fscache.h" #include "smb2proto.h" -#include "smb2status.h" +#include "../common/smb2status.h" static struct smb2_symlink_err_rsp *symlink_data (const struct kvec *iov) {
fs/smb/client/smb2inode.c +1 -1
@@ -24,7 +24,7 @@#include "smb2pdu.h" #include "smb2proto.h" #include "cached_dir.h" -#include "smb2status.h" +#include "../common/smb2status.h" static struct reparse_data_buffer *reparse_buf_ptr (struct kvec *iov) {
fs/smb/client/smb2maperror.c +1 -1
@@ -12,7 +12,7 @@#include "cifs_debug.h" #include "smb2pdu.h" #include "smb2proto.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" #include "trace.h"
fs/smb/client/smb2misc.c +1 -1
@@ -13,7 +13,7 @@#include "smb2proto.h" #include "cifs_debug.h" #include "cifs_unicode.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" #include "nterr.h" #include "cached_dir.h"
fs/smb/client/smb2ops.c +1 -1
@@ -21,7 +21,7 @@#include "cifsproto.h" #include "cifs_debug.h" #include "cifs_unicode.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" #include "cifs_ioctl.h" #include "smbdirect.h"
fs/smb/client/smb2pdu.c +1 -1
@@ -32,7 +32,7 @@#include "cifs_unicode.h" #include "cifs_debug.h" #include "ntlmssp.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" #include "cifspdu.h" #include "cifs_spnego.h"
fs/smb/client/smb2transport.c +1 -1
@@ -23,7 +23,7 @@#include "cifsproto.h" #include "smb2proto.h" #include "cifs_debug.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" static int
fs/smb/common/smb2status.h renamed from fs/smb/client/smb2status.h +2 -0
@@ -1769,3 +1769,5 @@ struct ntstatus {#define STATUS_IPSEC_INVALID_PACKET cpu_to_le32(0xC0360005)#define STATUS_IPSEC_INTEGRITY_CHECK_FAILED cpu_to_le32(0xC0360006)#define STATUS_IPSEC_CLEAR_TEXT_DROP cpu_to_le32(0xC0360007) +#define STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP cpu_to_le32(0xC05D0000) +#define STATUS_INVALID_LOCK_RANGE cpu_to_le32(0xC00001a1)
fs/smb/server/oplock.c +1 -1
@@ -10,7 +10,7 @@#include "oplock.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "connection.h" #include "mgmt/user_session.h" #include "mgmt/share_config.h"
fs/smb/server/server.c +1 -1
@@ -15,7 +15,7 @@#include "server.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "connection.h" #include "transport_ipc.h" #include "mgmt/user_session.h"
fs/smb/server/smb2misc.c +1 -1
@@ -7,7 +7,7 @@#include "glob.h" #include "nterr.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "mgmt/user_session.h" #include "connection.h"
fs/smb/server/smb2pdu.c +1 -1
@@ -30,7 +30,7 @@#include "server.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "ksmbd_work.h" #include "mgmt/user_config.h" #include "mgmt/share_config.h"
fs/smb/server/smb_common.c +1 -1
@@ -9,7 +9,7 @@#include "smb_common.h" #include "server.h" #include "misc.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "connection.h" #include "ksmbd_work.h" #include "mgmt/user_session.h"
fs/smb/server/smbstatus.h deleted +0 -1822
1,822 lines not on this page · raw message
fs/smb/server/transport_rdma.c +1 -1
@@ -21,7 +21,7 @@#include "glob.h" #include "connection.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "transport_rdma.h" #define SMB_DIRECT_PORT_IWARP 5445
Signature · 1 line
2.34.1
[email protected]
reviewerPATCH v2 12/12 smb: add comment to STATUS_MCA_OCCURED
In reply to [email protected]From: ChenXiaoSong <[email protected]>
Explained why the typo was not corrected.
--- fs/smb/common/smb2status.h | 4 ++++ 1 file changed, 4 insertions(+)
fs/smb/common/smb2status.h +4 -0
@@ -901,6 +901,10 @@ struct ntstatus {#define STATUS_DEVICE_ENUMERATION_ERROR cpu_to_le32(0xC0000366)#define STATUS_MOUNT_POINT_NOT_RESOLVED cpu_to_le32(0xC0000368)#define STATUS_INVALID_DEVICE_OBJECT_PARAMETER cpu_to_le32(0xC0000369) +/* +* 'OCCURED' is typo in MS-ERREF, it should be 'OCCURRED', +* but we'll keep it consistent with MS-ERREF. +*/ #define STATUS_MCA_OCCURED cpu_to_le32(0xC000036A)#define STATUS_DRIVER_BLOCKED_CRITICAL cpu_to_le32(0xC000036B)#define STATUS_DRIVER_BLOCKED cpu_to_le32(0xC000036C)
Signature · 1 line
2.34.1
Re: [PATCH v2 12/12] smb: add comment to STATUS_MCA_OCCURED
Quoted 6 lines · On Thu, Aug 22, 2024 at 5:24 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Explained why the typo was not corrected.
Signed-off-by ChenXiaoSong <[email protected]>
Looks ok.
Thanks.
Quoted 22 lines
--- fs/smb/common/smb2status.h | 4 ++++ 1 file changed, 4 insertions(+)fs/smb/common/smb2status.h +4
-1@@ -901,6 +901,10 @@ struct ntstatus {#define STATUS_DEVICE_ENUMERATION_ERROR cpu_to_le32(0xC0000366)#define STATUS_MOUNT_POINT_NOT_RESOLVED cpu_to_le32(0xC0000368)#define STATUS_INVALID_DEVICE_OBJECT_PARAMETER cpu_to_le32(0xC0000369) +/* +* 'OCCURED' is typo in MS-ERREF, it should be 'OCCURRED', +* but we'll keep it consistent with MS-ERREF. +*/ #define STATUS_MCA_OCCURED cpu_to_le32(0xC000036A)#define STATUS_DRIVER_BLOCKED_CRITICAL cpu_to_le32(0xC000036B)#define STATUS_DRIVER_BLOCKED cpu_to_le32(0xC000036C) --2.34.1
Merged patches 6, 7, 8, 9, 10, 11, 12 (the ones affecting the client e.g.) into cifs-2.6.git for-next-next branch (for 6.12-rc) and added Namjae's Reviewed-by for those that didn't already have it in the commit description.
dc470593e459 (HEAD -> for-next-next) smb: add comment to STATUS_MCA_OCCURED cda1ece3de80 smb: move SMB2 Status code to common header file 093aa95b1f89 smb: move some duplicate definitions to common/smbacl.h ef90cd1c8858 smb/client: rename cifs_ace to smb_ace 0628feffddec smb/client: rename cifs_acl to smb_acl d58459043a94 smb/client: rename cifs_sid to smb_sid d8fa64617131 smb/client: rename cifs_ntsd to smb_ntsd 5e51224d2afb (origin/for-next, for-next) smb/client: fix typo:GlobalMid_Sem -> GlobalMid_Lock
Quoted 67 lines · On Thu, Aug 22, 2024 at 3:25 AM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Fix some bugs in
smb2_open()of smb server.In order to maintain the code more easily, move some duplicate definitions to common header file.
Additionally, add some small cleanups to the patchset.
v1->v2:
- update patch #2 according to Namjae's suggestions.
- add patch #6~9 to rename 'cifs_ntsd' 'cifs_sid' 'cifs_acl' 'cifs_ace' according to Namjae's suggestions.
- add patch #12 to explained why the typo 'STATUS_MCA_OCCURED' was not corrected.v1: https://lore.kernel.org/all/[email protected]/
ChenXiaoSong (12):
smb/server: fix return value ofsmb2_open()smb/server: fix potential null-ptr-deref oflease_ctx_infoinsmb2_open()smb/server: remove useless assignment of '
file_present' insmb2_open()smb/client: fix typo:GlobalMid_Sem->GlobalMid_Locksmb/server: update misguided comment ofsmb2_allocate_rsp_buf()smb/client: renamecifs_ntsdtosmb_ntsd
smb/client: renamecifs_sidtosmb_sid
smb/client: renamecifs_acltosmb_acl
smb/client: renamecifs_acetosmb_ace
smb: move some duplicate definitions tocommon/smbacl.h
smb: move SMB2 Status code to common header file
smb: add comment toSTATUS_MCA_OCCUREDfs/smb/client/cifsacl.c | 224 +-- fs/smb/client/cifsacl.h | 99 +- fs/smb/client/cifsfs.c | 6 +- fs/smb/client/cifsglob.h | 22 +- fs/smb/client/cifsproto.h | 18 +- fs/smb/client/cifssmb.c | 6 +- fs/smb/client/smb2file.c | 2 +- fs/smb/client/smb2inode.c | 6 +- fs/smb/client/smb2maperror.c | 2 +- fs/smb/client/smb2misc.c | 2 +- fs/smb/client/smb2ops.c | 16 +- fs/smb/client/smb2pdu.c | 14 +- fs/smb/client/smb2pdu.h | 8 +- fs/smb/client/smb2proto.h | 2 +- fs/smb/client/smb2transport.c | 2 +- fs/smb/client/xattr.c | 4 +- fs/smb/{client => common}/smb2status.h | 6 + fs/smb/common/smbacl.h | 121 ++ fs/smb/server/oplock.c | 4 +- fs/smb/server/server.c | 2 +- fs/smb/server/smb2misc.c | 2 +- fs/smb/server/smb2pdu.c | 17 +- fs/smb/server/smb_common.c | 2 +- fs/smb/server/smbacl.h | 111 +- fs/smb/server/smbstatus.h | 1822 ------------------------ fs/smb/server/transport_rdma.c | 2 +- 26 files changed, 314 insertions(+), 2208 deletions(-) rename fs/smb/{client => common}/smb2status.h (99%) create mode 100644 fs/smb/common/smbacl.h delete mode 100644 fs/smb/server/smbstatus.h--
2.34.1
Signature · 3 lines
Thanks, Steve
The following patches from the series have been added to cifs-2.6.git for-next (the other patches in the series were either for fs/smb/server rather than the client, or have already been merged). Let me know if any objections or problems seen.
d837dec2296c smb: add comment to STATUS_MCA_OCCURED 15dd39d9da2b smb: move SMB2 Status code to common header file 5ce486228d95 smb: move some duplicate definitions to common/smbacl.h 1e4b28faf320 smb/client: rename cifs_ace to smb_ace 664987e5e550 smb/client: rename cifs_acl to smb_acl 624d2ce94277 smb/client: rename cifs_sid to smb_sid 8335848d54c1 smb/client: rename cifs_ntsd to smb_ntsd
Quoted 67 lines · On Thu, Aug 22, 2024 at 3:25 AM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Fix some bugs in
smb2_open()of smb server.In order to maintain the code more easily, move some duplicate definitions to common header file.
Additionally, add some small cleanups to the patchset.
v1->v2:
- update patch #2 according to Namjae's suggestions.
- add patch #6~9 to rename 'cifs_ntsd' 'cifs_sid' 'cifs_acl' 'cifs_ace' according to Namjae's suggestions.
- add patch #12 to explained why the typo 'STATUS_MCA_OCCURED' was not corrected.v1: https://lore.kernel.org/all/[email protected]/
ChenXiaoSong (12):
smb/server: fix return value ofsmb2_open()smb/server: fix potential null-ptr-deref oflease_ctx_infoinsmb2_open()smb/server: remove useless assignment of '
file_present' insmb2_open()smb/client: fix typo:GlobalMid_Sem->GlobalMid_Locksmb/server: update misguided comment ofsmb2_allocate_rsp_buf()smb/client: renamecifs_ntsdtosmb_ntsd
smb/client: renamecifs_sidtosmb_sid
smb/client: renamecifs_acltosmb_acl
smb/client: renamecifs_acetosmb_ace
smb: move some duplicate definitions tocommon/smbacl.h
smb: move SMB2 Status code to common header file
smb: add comment toSTATUS_MCA_OCCUREDfs/smb/client/cifsacl.c | 224 +-- fs/smb/client/cifsacl.h | 99 +- fs/smb/client/cifsfs.c | 6 +- fs/smb/client/cifsglob.h | 22 +- fs/smb/client/cifsproto.h | 18 +- fs/smb/client/cifssmb.c | 6 +- fs/smb/client/smb2file.c | 2 +- fs/smb/client/smb2inode.c | 6 +- fs/smb/client/smb2maperror.c | 2 +- fs/smb/client/smb2misc.c | 2 +- fs/smb/client/smb2ops.c | 16 +- fs/smb/client/smb2pdu.c | 14 +- fs/smb/client/smb2pdu.h | 8 +- fs/smb/client/smb2proto.h | 2 +- fs/smb/client/smb2transport.c | 2 +- fs/smb/client/xattr.c | 4 +- fs/smb/{client => common}/smb2status.h | 6 + fs/smb/common/smbacl.h | 121 ++ fs/smb/server/oplock.c | 4 +- fs/smb/server/server.c | 2 +- fs/smb/server/smb2misc.c | 2 +- fs/smb/server/smb2pdu.c | 17 +- fs/smb/server/smb_common.c | 2 +- fs/smb/server/smbacl.h | 111 +- fs/smb/server/smbstatus.h | 1822 ------------------------ fs/smb/server/transport_rdma.c | 2 +- 26 files changed, 314 insertions(+), 2208 deletions(-) rename fs/smb/{client => common}/smb2status.h (99%) create mode 100644 fs/smb/common/smbacl.h delete mode 100644 fs/smb/server/smbstatus.h--
2.34.1
Signature · 3 lines
Thanks, Steve