@@ -56,6 +56,35 @@ static inline __u32 file_create_options(struct dentry *dentry)
56
56
return 0 ;
57
57
}
58
58
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
+
59
88
/*
60
89
* note: If cfile is passed, the reference to it is dropped here.
61
90
* 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,
69
98
__u32 desired_access , __u32 create_disposition ,
70
99
__u32 create_options , umode_t mode , struct kvec * in_iov ,
71
100
int * cmds , int num_cmds , struct cifsFileInfo * cfile ,
72
- __u8 * * extbuf , size_t * extbuflen ,
73
101
struct kvec * out_iov , int * out_buftype )
74
102
{
75
103
@@ -494,21 +522,9 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
494
522
& rsp_iov [i + 1 ], sizeof (idata -> posix_fi ) /* add SIDs */ ,
495
523
(char * )& idata -> posix_fi );
496
524
}
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
+
512
528
SMB2_query_info_free (& rqst [num_rqst ++ ]);
513
529
if (rc )
514
530
trace_smb3_posix_query_info_compound_err (xid , ses -> Suid ,
@@ -693,9 +709,8 @@ int smb2_query_path_info(const unsigned int xid,
693
709
cifs_get_readable_path (tcon , full_path , & cfile );
694
710
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
695
711
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 );
699
714
hdr = out_iov [0 ].iov_base ;
700
715
/*
701
716
* 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,
722
737
cifs_get_readable_path (tcon , full_path , & cfile );
723
738
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
724
739
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 );
727
742
break ;
728
743
case - EREMOTE :
729
744
break ;
@@ -750,19 +765,13 @@ int smb311_posix_query_path_info(const unsigned int xid,
750
765
struct cifs_tcon * tcon ,
751
766
struct cifs_sb_info * cifs_sb ,
752
767
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 )
756
769
{
757
770
int rc ;
758
771
__u32 create_options = 0 ;
759
772
struct cifsFileInfo * cfile ;
760
773
struct kvec in_iov [2 ], out_iov [3 ] = {};
761
774
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 ;
766
775
int cmds [2 ] = { SMB2_OP_POSIX_QUERY_INFO , };
767
776
int i , num_cmds ;
768
777
@@ -782,8 +791,8 @@ int smb311_posix_query_path_info(const unsigned int xid,
782
791
cifs_get_readable_path (tcon , full_path , & cfile );
783
792
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
784
793
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 );
787
796
/*
788
797
* If first iov is unset, then SMB session was dropped or we've got a
789
798
* cached open file (@cfile).
@@ -810,32 +819,12 @@ int smb311_posix_query_path_info(const unsigned int xid,
810
819
cifs_get_readable_path (tcon , full_path , & cfile );
811
820
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
812
821
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 );
815
824
break ;
816
825
}
817
826
818
827
out :
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 );
839
828
for (i = 0 ; i < ARRAY_SIZE (out_buftype ); i ++ )
840
829
free_rsp_buf (out_buftype [i ], out_iov [i ].iov_base );
841
830
return rc ;
@@ -848,9 +837,9 @@ smb2_mkdir(const unsigned int xid, struct inode *parent_inode, umode_t mode,
848
837
{
849
838
return smb2_compound_op (xid , tcon , cifs_sb , name ,
850
839
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 );
854
843
}
855
844
856
845
void
@@ -875,7 +864,7 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name,
875
864
FILE_WRITE_ATTRIBUTES , FILE_CREATE ,
876
865
CREATE_NOT_FILE , ACL_NO_MODE , & in_iov ,
877
866
& (int ){SMB2_OP_SET_INFO }, 1 ,
878
- cfile , NULL , NULL , NULL , NULL );
867
+ cfile , NULL , NULL );
879
868
if (tmprc == 0 )
880
869
cifs_i -> cifsAttrs = dosattrs ;
881
870
}
@@ -887,8 +876,9 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
887
876
drop_cached_dir_by_name (xid , tcon , name , cifs_sb );
888
877
return smb2_compound_op (xid , tcon , cifs_sb , name ,
889
878
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 );
892
882
}
893
883
894
884
int
@@ -897,8 +887,9 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
897
887
{
898
888
return smb2_compound_op (xid , tcon , cifs_sb , name , DELETE , FILE_OPEN ,
899
889
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 );
902
893
}
903
894
904
895
static 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,
919
910
in_iov .iov_base = smb2_to_name ;
920
911
in_iov .iov_len = 2 * UniStrnlen ((wchar_t * )smb2_to_name , PATH_MAX );
921
912
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 );
924
915
smb2_rename_path :
925
916
kfree (smb2_to_name );
926
917
return rc ;
@@ -971,7 +962,7 @@ smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
971
962
FILE_WRITE_DATA , FILE_OPEN ,
972
963
0 , ACL_NO_MODE , & in_iov ,
973
964
& (int ){SMB2_OP_SET_EOF }, 1 ,
974
- cfile , NULL , NULL , NULL , NULL );
965
+ cfile , NULL , NULL );
975
966
}
976
967
977
968
int
@@ -999,8 +990,8 @@ smb2_set_file_info(struct inode *inode, const char *full_path,
999
990
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
1000
991
FILE_WRITE_ATTRIBUTES , FILE_OPEN ,
1001
992
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 );
1004
995
cifs_put_tlink (tlink );
1005
996
return rc ;
1006
997
}
@@ -1035,7 +1026,7 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data,
1035
1026
cifs_get_writable_path (tcon , full_path , FIND_WR_ANY , & cfile );
1036
1027
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
1037
1028
da , cd , co , ACL_NO_MODE , in_iov ,
1038
- cmds , 2 , cfile , NULL , NULL , NULL , NULL );
1029
+ cmds , 2 , cfile , NULL , NULL );
1039
1030
if (!rc ) {
1040
1031
rc = smb311_posix_get_inode_info (& new , full_path ,
1041
1032
data , sb , xid );
@@ -1045,7 +1036,7 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data,
1045
1036
cifs_get_writable_path (tcon , full_path , FIND_WR_ANY , & cfile );
1046
1037
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
1047
1038
da , cd , co , ACL_NO_MODE , in_iov ,
1048
- cmds , 2 , cfile , NULL , NULL , NULL , NULL );
1039
+ cmds , 2 , cfile , NULL , NULL );
1049
1040
if (!rc ) {
1050
1041
rc = cifs_get_inode_info (& new , full_path ,
1051
1042
data , sb , xid , NULL );
@@ -1072,8 +1063,8 @@ int smb2_query_reparse_point(const unsigned int xid,
1072
1063
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path ,
1073
1064
FILE_READ_ATTRIBUTES , FILE_OPEN ,
1074
1065
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 );
1077
1068
if (rc )
1078
1069
goto out ;
1079
1070
0 commit comments