smb: client: fix parsing of SMB3.1.1 POSIX create context
Subsystems (2)
PATCH 1/4 smb: client: fix parsing of SMB3.1.1 POSIX create context
The data offset for the SMB3.1.1 POSIX create context will always be 8-byte aligned so having the check 'noff + nlen >= doff' in smb2_parse_contexts() is wrong as it will lead to -EINVAL because noff
+ nlen == doff.
Fix the sanity check to correctly handle aligned create context data.
--- fs/smb/client/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/smb2pdu.c +1 -1
@@ -2308,7 +2308,7 @@ int smb2_parse_contexts(struct TCP_Server_Info *server, noff =le16_to_cpu (cc->NameOffset); nlen =le16_to_cpu (cc->NameLength); -if (noff + nlen >= doff) +if (noff + nlen > doff)return -EINVAL ; name = (char *)cc + noff;
Signature · 1 line
2.43.0
PATCH 2/4 smb: client: parse owner/group when creating reparse points
Parse owner/group when creating special files and symlinks under SMB3.1.1 POSIX mounts.
Move the parsing of owner/group to smb2_compound_op() so we don't have to duplicate it in both smb2_get_reparse_inode() and smb311_posix_query_path_info().
--- fs/smb/client/cifsglob.h | 2 + fs/smb/client/inode.c | 25 +++----- fs/smb/client/smb2inode.c | 127 ++++++++++++++++++-------------------- fs/smb/client/smb2proto.h | 4 +- 4 files changed, 70 insertions(+), 88 deletions(-)
fs/smb/client/cifsglob.h +2 -0
@@ -204,6 +204,8 @@ struct cifs_open_info_data { }; } reparse;char *symlink_target; +struct cifs_sid posix_owner; +struct cifs_sid posix_group;union {struct smb2_file_all_info fi;struct smb311_posix_qinfo posix_fi;
fs/smb/client/inode.c +8 -17
@@ -665,8 +665,6 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const unsigned char *path,/* Fill a cifs_fattr struct with info from POSIX info struct */ static void smb311_posix_info_to_fattr (struct cifs_fattr *fattr,struct cifs_open_info_data *data, -struct cifs_sid *owner, -struct cifs_sid *group,struct super_block *sb) {struct smb311_posix_qinfo *info = &data->posix_fi;
@@ -722,8 +720,8 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr, fattr->cf_symlink_target = data->symlink_target; data->symlink_target =NULL ; } -sid_to_id (cifs_sb, owner, fattr,SIDOWNER ); -sid_to_id (cifs_sb, group, fattr,SIDGROUP ); +sid_to_id (cifs_sb, &data->posix_owner, fattr,SIDOWNER ); +sid_to_id (cifs_sb, &data->posix_group, fattr,SIDGROUP );cifs_dbg (FYI ,"POSIX query info: mode 0x%x uniqueid 0x%llx nlink %d\n" , fattr->cf_mode, fattr->cf_uniqueid, fattr->cf_nlink);
@@ -1070,9 +1068,7 @@ static int reparse_info_to_fattr(struct cifs_open_info_data *data,const unsigned int xid, struct cifs_tcon *tcon, const char *full_path, - struct cifs_fattr *fattr, - struct cifs_sid *owner, - struct cifs_sid *group) + struct cifs_fattr *fattr) { struct TCP_Server_Info *server = tcon->ses->server;struct cifs_sb_info *cifs_sb =CIFS_SB (sb);
@@ -1117,7 +1113,7 @@ static int reparse_info_to_fattr(struct cifs_open_info_data *data, }if (tcon->posix_extensions) -smb311_posix_info_to_fattr (fattr, data, owner, group, sb); +smb311_posix_info_to_fattr (fattr, data, sb);else cifs_open_info_to_fattr (fattr, data, sb); out:
@@ -1171,8 +1167,7 @@ static int cifs_get_fattr(struct cifs_open_info_data *data,*/ if (cifs_open_data_reparse (data)) { rc =reparse_info_to_fattr (data, sb, xid, tcon, - full_path, fattr, -NULL ,NULL ); + full_path, fattr); }else {cifs_open_info_to_fattr (fattr, data, sb); }
@@ -1320,7 +1315,6 @@ static int smb311_posix_get_fattr(struct cifs_open_info_data *data,struct cifs_sb_info *cifs_sb =CIFS_SB (sb);struct cifs_tcon *tcon;struct tcon_link *tlink; -struct cifs_sid owner, group;int tmprc;int rc =0 ;
@@ -1334,8 +1328,7 @@ static int smb311_posix_get_fattr(struct cifs_open_info_data *data,*/ if (!data) { rc =smb311_posix_query_path_info (xid, tcon, cifs_sb, - full_path, &tmp_data, - &owner, &group); + full_path, &tmp_data); data = &tmp_data; }
@@ -1347,11 +1340,9 @@ static int smb311_posix_get_fattr(struct cifs_open_info_data *data,case 0 :if (cifs_open_data_reparse (data)) { rc =reparse_info_to_fattr (data, sb, xid, tcon, - full_path, fattr, - &owner, &group); + full_path, fattr); }else { -smb311_posix_info_to_fattr (fattr, data, - &owner, &group, sb); +smb311_posix_info_to_fattr (fattr, data, sb); }break ;case -EREMOTE :
fs/smb/client/smb2inode.c +59 -68
246 lines not on this page · raw message
fs/smb/client/smb2proto.h +1 -3
@@ -299,9 +299,7 @@ int smb311_posix_query_path_info(const unsigned int xid,struct cifs_tcon *tcon, struct cifs_sb_info *cifs_sb, const char *full_path, - struct cifs_open_info_data *data, - struct cifs_sid *owner, - struct cifs_sid *group); + struct cifs_open_info_data *data);int posix_info_parse (const void *beg,const void *end,struct smb2_posix_info_parsed *out);int posix_info_sid_size (const void *beg,const void *end);
Signature · 1 line
2.43.0
PATCH 3/4 smb: client: get rid of smb311_posix_query_path_info()
In reply to Paulo AlcantaraMerge smb311_posix_query_path_info into ->query_path_info() to get rid of duplicate code.
--- fs/smb/client/inode.c | 4 +- fs/smb/client/smb2inode.c | 115 +++++++++++--------------------------- 2 files changed, 36 insertions(+), 83 deletions(-)
fs/smb/client/inode.c +3 -1
@@ -1312,6 +1312,7 @@ static int smb311_posix_get_fattr(struct cifs_open_info_data *data, const unsigned int xid) {struct cifs_open_info_data tmp_data = {}; +struct TCP_Server_Info *server;struct cifs_sb_info *cifs_sb =CIFS_SB (sb);struct cifs_tcon *tcon;struct tcon_link *tlink;
@@ -1322,12 +1323,13 @@ static int smb311_posix_get_fattr(struct cifs_open_info_data *data,if (IS_ERR (tlink))return PTR_ERR (tlink); tcon =tlink_tcon (tlink); + server = tcon->ses->server;/* * 1. Fetch file metadata if not provided (data) */ if (!data) { - rc =smb311_posix_query_path_info (xid, tcon, cifs_sb, + rc = server->ops->query_path_info (xid, tcon, cifs_sb, full_path, &tmp_data); data = &tmp_data; }
fs/smb/client/smb2inode.c +33 -82
141 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 4/4 smb: client: don't clobber ->i_rdev from cached reparse points
In reply to Paulo AlcantaraDon't clobber ->i_rdev from valid reparse inodes over readdir(2) as it can't be provided by query dir responses.
--- fs/smb/client/readdir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/client/readdir.c +3 -3
@@ -133,14 +133,14 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,* Query dir responses don't provide enough * information about reparse points other than * their reparse tags. Save an invalidation by -* not clobbering the existing mode, size and -* symlink target (if any) when reparse tag and -* ctime haven't changed. +* not clobbering some existing attributes when +* reparse tag and ctime haven't changed. */ rc =0 ;if (fattr->cf_cifsattrs &ATTR_REPARSE ) {if (likely (reparse_inode_match (inode, fattr))) { fattr->cf_mode = inode->i_mode; + fattr->cf_rdev = inode->i_rdev; fattr->cf_eof =CIFS_I (inode)->server_eof; fattr->cf_symlink_target =NULL ; }else {
Signature · 1 line
2.43.0
merged this 4 patch series into cifs-2.6.git for-next pending additional review and testing
Quoted 30 lines · Paulo Alcantara
The data offset for the SMB3.1.1 POSIX create context will always be 8-byte aligned so having the check 'noff + nlen >= doff' in
smb2_parse_contexts()is wrong as it will lead to-EINVALbecause noff
+ nlen == doff.Fix the sanity check to correctly handle aligned create context data.
Fixes af1689a9b770 ("smb: client: fix potential OOBs in smb2_parse_contexts()")Signed-off-by Paulo Alcantara <[email protected]>--- fs/smb/client/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smb2pdu.c +1
-2@@ -2308,7 +2308,7 @@ int smb2_parse_contexts(struct TCP_Server_Info *server, noff =le16_to_cpu (cc->NameOffset); nlen =le16_to_cpu (cc->NameLength); -if (noff + nlen >= doff) +if (noff + nlen > doff)return -EINVAL ; name = (char *)cc + noff; --2.43.0
Signature · 3 lines
Thanks, Steve