@@ -56,6 +56,35 @@ static inline __u32 file_create_options(struct dentry *dentry)
5656 return 0 ;
5757}
5858
59+ /* Parse owner and group from SMB3.1.1 POSIX query info */
60+ static int parse_posix_sids (struct cifs_open_info_data * data ,
61+ struct kvec * rsp_iov )
62+ {
63+ struct smb2_query_info_rsp * qi = rsp_iov -> iov_base ;
64+ unsigned int out_len = le32_to_cpu (qi -> OutputBufferLength );
65+ unsigned int qi_len = sizeof (data -> posix_fi );
66+ int owner_len , group_len ;
67+ u8 * sidsbuf , * sidsbuf_end ;
68+
69+ if (out_len <= qi_len )
70+ return - EINVAL ;
71+
72+ sidsbuf = (u8 * )qi + le16_to_cpu (qi -> OutputBufferOffset ) + qi_len ;
73+ sidsbuf_end = sidsbuf + out_len - qi_len ;
74+
75+ owner_len = posix_info_sid_size (sidsbuf , sidsbuf_end );
76+ if (owner_len == -1 )
77+ return - EINVAL ;
78+
79+ memcpy (& data -> posix_owner , sidsbuf , owner_len );
80+ group_len = posix_info_sid_size (sidsbuf + owner_len , sidsbuf_end );
81+ if (group_len == -1 )
82+ return - EINVAL ;
83+
84+ memcpy (& data -> posix_group , sidsbuf + owner_len , group_len );
85+ return 0 ;
86+ }
87+
5988/*
6089 * note: If cfile is passed, the reference to it is dropped here.
6190 * So make sure that you do not reuse cfile after return from this func.
@@ -69,7 +98,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
6998 __u32 desired_access , __u32 create_disposition ,
7099 __u32 create_options , umode_t mode , struct kvec * in_iov ,
71100 int * cmds , int num_cmds , struct cifsFileInfo * cfile ,
72- __u8 * * extbuf , size_t * extbuflen ,
73101 struct kvec * out_iov , int * out_buftype )
74102{
75103
@@ -494,21 +522,9 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
494522 & rsp_iov [i + 1 ], sizeof (idata -> posix_fi ) /* add SIDs */ ,
495523 (char * )& idata -> posix_fi );
496524 }
497- if (rc == 0 ) {
498- unsigned int length = le32_to_cpu (qi_rsp -> OutputBufferLength );
499-
500- if (length > sizeof (idata -> posix_fi )) {
501- char * base = (char * )rsp_iov [i + 1 ].iov_base +
502- le16_to_cpu (qi_rsp -> OutputBufferOffset ) +
503- sizeof (idata -> posix_fi );
504- * extbuflen = length - sizeof (idata -> posix_fi );
505- * extbuf = kmemdup (base , * extbuflen , GFP_KERNEL );
506- if (!* extbuf )
507- rc = - ENOMEM ;
508- } else {
509- rc = - EINVAL ;
510- }
511- }
525+ if (rc == 0 )
526+ rc = parse_posix_sids (idata , & rsp_iov [i + 1 ]);
527+
512528 SMB2_query_info_free (& rqst [num_rqst ++ ]);
513529 if (rc )
514530 trace_smb3_posix_query_info_compound_err (xid , ses -> Suid ,
@@ -693,9 +709,8 @@ int smb2_query_path_info(const unsigned int xid,
693709 cifs_get_readable_path (tcon , full_path , & cfile );
694710 rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
695711 FILE_READ_ATTRIBUTES , FILE_OPEN ,
696- create_options , ACL_NO_MODE ,
697- in_iov , cmds , 1 , cfile ,
698- NULL , NULL , out_iov , out_buftype );
712+ create_options , ACL_NO_MODE , in_iov ,
713+ cmds , 1 , cfile , out_iov , out_buftype );
699714 hdr = out_iov [0 ].iov_base ;
700715 /*
701716 * If first iov is unset, then SMB session was dropped or we've got a
@@ -722,8 +737,8 @@ int smb2_query_path_info(const unsigned int xid,
722737 cifs_get_readable_path (tcon , full_path , & cfile );
723738 rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
724739 FILE_READ_ATTRIBUTES , FILE_OPEN ,
725- create_options , ACL_NO_MODE , in_iov , cmds ,
726- num_cmds , cfile , NULL , NULL , NULL , NULL );
740+ create_options , ACL_NO_MODE , in_iov ,
741+ cmds , num_cmds , cfile , NULL , NULL );
727742 break ;
728743 case - EREMOTE :
729744 break ;
@@ -750,19 +765,13 @@ int smb311_posix_query_path_info(const unsigned int xid,
750765 struct cifs_tcon * tcon ,
751766 struct cifs_sb_info * cifs_sb ,
752767 const char * full_path ,
753- struct cifs_open_info_data * data ,
754- struct cifs_sid * owner ,
755- struct cifs_sid * group )
768+ struct cifs_open_info_data * data )
756769{
757770 int rc ;
758771 __u32 create_options = 0 ;
759772 struct cifsFileInfo * cfile ;
760773 struct kvec in_iov [2 ], out_iov [3 ] = {};
761774 int out_buftype [3 ] = {};
762- __u8 * sidsbuf = NULL ;
763- __u8 * sidsbuf_end = NULL ;
764- size_t sidsbuflen = 0 ;
765- size_t owner_len , group_len ;
766775 int cmds [2 ] = { SMB2_OP_POSIX_QUERY_INFO , };
767776 int i , num_cmds ;
768777
@@ -782,8 +791,8 @@ int smb311_posix_query_path_info(const unsigned int xid,
782791 cifs_get_readable_path (tcon , full_path , & cfile );
783792 rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
784793 FILE_READ_ATTRIBUTES , FILE_OPEN ,
785- create_options , ACL_NO_MODE , in_iov , cmds , 1 ,
786- cfile , & sidsbuf , & sidsbuflen , out_iov , out_buftype );
794+ create_options , ACL_NO_MODE , in_iov ,
795+ cmds , 1 , cfile , out_iov , out_buftype );
787796 /*
788797 * If first iov is unset, then SMB session was dropped or we've got a
789798 * cached open file (@cfile).
@@ -810,32 +819,12 @@ int smb311_posix_query_path_info(const unsigned int xid,
810819 cifs_get_readable_path (tcon , full_path , & cfile );
811820 rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
812821 FILE_READ_ATTRIBUTES , FILE_OPEN ,
813- create_options , ACL_NO_MODE , in_iov , cmds ,
814- num_cmds , cfile , & sidsbuf , & sidsbuflen , NULL , NULL );
822+ create_options , ACL_NO_MODE , in_iov ,
823+ cmds , num_cmds , cfile , NULL , NULL );
815824 break ;
816825 }
817826
818827out :
819- if (rc == 0 ) {
820- sidsbuf_end = sidsbuf + sidsbuflen ;
821-
822- owner_len = posix_info_sid_size (sidsbuf , sidsbuf_end );
823- if (owner_len == -1 ) {
824- rc = - EINVAL ;
825- goto out ;
826- }
827- memcpy (owner , sidsbuf , owner_len );
828-
829- group_len = posix_info_sid_size (
830- sidsbuf + owner_len , sidsbuf_end );
831- if (group_len == -1 ) {
832- rc = - EINVAL ;
833- goto out ;
834- }
835- memcpy (group , sidsbuf + owner_len , group_len );
836- }
837-
838- kfree (sidsbuf );
839828 for (i = 0 ; i < ARRAY_SIZE (out_buftype ); i ++ )
840829 free_rsp_buf (out_buftype [i ], out_iov [i ].iov_base );
841830 return rc ;
@@ -848,9 +837,9 @@ smb2_mkdir(const unsigned int xid, struct inode *parent_inode, umode_t mode,
848837{
849838 return smb2_compound_op (xid , tcon , cifs_sb , name ,
850839 FILE_WRITE_ATTRIBUTES , FILE_CREATE ,
851- CREATE_NOT_FILE , mode , NULL ,
852- & (int ){SMB2_OP_MKDIR }, 1 ,
853- NULL , NULL , NULL , NULL , NULL );
840+ CREATE_NOT_FILE , mode ,
841+ NULL , & (int ){SMB2_OP_MKDIR }, 1 ,
842+ NULL , NULL , NULL );
854843}
855844
856845void
@@ -875,7 +864,7 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name,
875864 FILE_WRITE_ATTRIBUTES , FILE_CREATE ,
876865 CREATE_NOT_FILE , ACL_NO_MODE , & in_iov ,
877866 & (int ){SMB2_OP_SET_INFO }, 1 ,
878- cfile , NULL , NULL , NULL , NULL );
867+ cfile , NULL , NULL );
879868 if (tmprc == 0 )
880869 cifs_i -> cifsAttrs = dosattrs ;
881870}
@@ -887,8 +876,9 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
887876 drop_cached_dir_by_name (xid , tcon , name , cifs_sb );
888877 return smb2_compound_op (xid , tcon , cifs_sb , name ,
889878 DELETE , FILE_OPEN , CREATE_NOT_FILE ,
890- ACL_NO_MODE , NULL , & (int ){SMB2_OP_RMDIR }, 1 ,
891- NULL , NULL , NULL , NULL , NULL );
879+ ACL_NO_MODE , NULL ,
880+ & (int ){SMB2_OP_RMDIR }, 1 ,
881+ NULL , NULL , NULL );
892882}
893883
894884int
@@ -897,8 +887,9 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
897887{
898888 return smb2_compound_op (xid , tcon , cifs_sb , name , DELETE , FILE_OPEN ,
899889 CREATE_DELETE_ON_CLOSE | OPEN_REPARSE_POINT ,
900- ACL_NO_MODE , NULL , & (int ){SMB2_OP_DELETE }, 1 ,
901- NULL , NULL , NULL , NULL , NULL );
890+ ACL_NO_MODE , NULL ,
891+ & (int ){SMB2_OP_DELETE }, 1 ,
892+ NULL , NULL , NULL );
902893}
903894
904895static int smb2_set_path_attr (const unsigned int xid , struct cifs_tcon * tcon ,
@@ -919,8 +910,8 @@ static int smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
919910 in_iov .iov_base = smb2_to_name ;
920911 in_iov .iov_len = 2 * UniStrnlen ((wchar_t * )smb2_to_name , PATH_MAX );
921912 rc = smb2_compound_op (xid , tcon , cifs_sb , from_name , access ,
922- FILE_OPEN , create_options , ACL_NO_MODE , & in_iov ,
923- & command , 1 , cfile , NULL , NULL , NULL , NULL );
913+ FILE_OPEN , create_options , ACL_NO_MODE ,
914+ & in_iov , & command , 1 , cfile , NULL , NULL );
924915smb2_rename_path :
925916 kfree (smb2_to_name );
926917 return rc ;
@@ -971,7 +962,7 @@ smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
971962 FILE_WRITE_DATA , FILE_OPEN ,
972963 0 , ACL_NO_MODE , & in_iov ,
973964 & (int ){SMB2_OP_SET_EOF }, 1 ,
974- cfile , NULL , NULL , NULL , NULL );
965+ cfile , NULL , NULL );
975966}
976967
977968int
@@ -999,8 +990,8 @@ smb2_set_file_info(struct inode *inode, const char *full_path,
999990 rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
1000991 FILE_WRITE_ATTRIBUTES , FILE_OPEN ,
1001992 0 , ACL_NO_MODE , & in_iov ,
1002- & (int ){SMB2_OP_SET_INFO }, 1 , cfile ,
1003- NULL , NULL , NULL , NULL );
993+ & (int ){SMB2_OP_SET_INFO }, 1 ,
994+ cfile , NULL , NULL );
1004995 cifs_put_tlink (tlink );
1005996 return rc ;
1006997}
@@ -1035,7 +1026,7 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data,
10351026 cifs_get_writable_path (tcon , full_path , FIND_WR_ANY , & cfile );
10361027 rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
10371028 da , cd , co , ACL_NO_MODE , in_iov ,
1038- cmds , 2 , cfile , NULL , NULL , NULL , NULL );
1029+ cmds , 2 , cfile , NULL , NULL );
10391030 if (!rc ) {
10401031 rc = smb311_posix_get_inode_info (& new , full_path ,
10411032 data , sb , xid );
@@ -1045,7 +1036,7 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data,
10451036 cifs_get_writable_path (tcon , full_path , FIND_WR_ANY , & cfile );
10461037 rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
10471038 da , cd , co , ACL_NO_MODE , in_iov ,
1048- cmds , 2 , cfile , NULL , NULL , NULL , NULL );
1039+ cmds , 2 , cfile , NULL , NULL );
10491040 if (!rc ) {
10501041 rc = cifs_get_inode_info (& new , full_path ,
10511042 data , sb , xid , NULL );
@@ -1072,8 +1063,8 @@ int smb2_query_reparse_point(const unsigned int xid,
10721063 rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
10731064 FILE_READ_ATTRIBUTES , FILE_OPEN ,
10741065 OPEN_REPARSE_POINT , ACL_NO_MODE , & in_iov ,
1075- & (int ){SMB2_OP_GET_REPARSE }, 1 , cfile ,
1076- NULL , NULL , NULL , NULL );
1066+ & (int ){SMB2_OP_GET_REPARSE }, 1 ,
1067+ cfile , NULL , NULL );
10771068 if (rc )
10781069 goto out ;
10791070
0 commit comments