@@ -1607,17 +1607,18 @@ static int krb5_authenticate(struct ksmbd_work *work,
1607
1607
out_len = work -> response_sz -
1608
1608
(le16_to_cpu (rsp -> SecurityBufferOffset ) + 4 );
1609
1609
1610
- /* Check previous session */
1611
- prev_sess_id = le64_to_cpu (req -> PreviousSessionId );
1612
- if (prev_sess_id && prev_sess_id != sess -> id )
1613
- destroy_previous_session (conn , sess -> user , prev_sess_id );
1614
-
1615
1610
retval = ksmbd_krb5_authenticate (sess , in_blob , in_len ,
1616
1611
out_blob , & out_len );
1617
1612
if (retval ) {
1618
1613
ksmbd_debug (SMB , "krb5 authentication failed\n" );
1619
1614
return - EINVAL ;
1620
1615
}
1616
+
1617
+ /* Check previous session */
1618
+ prev_sess_id = le64_to_cpu (req -> PreviousSessionId );
1619
+ if (prev_sess_id && prev_sess_id != sess -> id )
1620
+ destroy_previous_session (conn , sess -> user , prev_sess_id );
1621
+
1621
1622
rsp -> SecurityBufferLength = cpu_to_le16 (out_len );
1622
1623
1623
1624
if ((conn -> sign || server_conf .enforced_signing ) ||
@@ -4871,8 +4872,13 @@ static int get_file_standard_info(struct smb2_query_info_rsp *rsp,
4871
4872
sinfo = (struct smb2_file_standard_info * )rsp -> Buffer ;
4872
4873
delete_pending = ksmbd_inode_pending_delete (fp );
4873
4874
4874
- sinfo -> AllocationSize = cpu_to_le64 (stat .blocks << 9 );
4875
- sinfo -> EndOfFile = S_ISDIR (stat .mode ) ? 0 : cpu_to_le64 (stat .size );
4875
+ if (ksmbd_stream_fd (fp ) == false) {
4876
+ sinfo -> AllocationSize = cpu_to_le64 (stat .blocks << 9 );
4877
+ sinfo -> EndOfFile = S_ISDIR (stat .mode ) ? 0 : cpu_to_le64 (stat .size );
4878
+ } else {
4879
+ sinfo -> AllocationSize = cpu_to_le64 (fp -> stream .size );
4880
+ sinfo -> EndOfFile = cpu_to_le64 (fp -> stream .size );
4881
+ }
4876
4882
sinfo -> NumberOfLinks = cpu_to_le32 (get_nlink (& stat ) - delete_pending );
4877
4883
sinfo -> DeletePending = delete_pending ;
4878
4884
sinfo -> Directory = S_ISDIR (stat .mode ) ? 1 : 0 ;
@@ -4935,9 +4941,14 @@ static int get_file_all_info(struct ksmbd_work *work,
4935
4941
file_info -> ChangeTime = cpu_to_le64 (time );
4936
4942
file_info -> Attributes = fp -> f_ci -> m_fattr ;
4937
4943
file_info -> Pad1 = 0 ;
4938
- file_info -> AllocationSize =
4939
- cpu_to_le64 (stat .blocks << 9 );
4940
- file_info -> EndOfFile = S_ISDIR (stat .mode ) ? 0 : cpu_to_le64 (stat .size );
4944
+ if (ksmbd_stream_fd (fp ) == false) {
4945
+ file_info -> AllocationSize =
4946
+ cpu_to_le64 (stat .blocks << 9 );
4947
+ file_info -> EndOfFile = S_ISDIR (stat .mode ) ? 0 : cpu_to_le64 (stat .size );
4948
+ } else {
4949
+ file_info -> AllocationSize = cpu_to_le64 (fp -> stream .size );
4950
+ file_info -> EndOfFile = cpu_to_le64 (fp -> stream .size );
4951
+ }
4941
4952
file_info -> NumberOfLinks =
4942
4953
cpu_to_le32 (get_nlink (& stat ) - delete_pending );
4943
4954
file_info -> DeletePending = delete_pending ;
@@ -4946,7 +4957,10 @@ static int get_file_all_info(struct ksmbd_work *work,
4946
4957
file_info -> IndexNumber = cpu_to_le64 (stat .ino );
4947
4958
file_info -> EASize = 0 ;
4948
4959
file_info -> AccessFlags = fp -> daccess ;
4949
- file_info -> CurrentByteOffset = cpu_to_le64 (fp -> filp -> f_pos );
4960
+ if (ksmbd_stream_fd (fp ) == false)
4961
+ file_info -> CurrentByteOffset = cpu_to_le64 (fp -> filp -> f_pos );
4962
+ else
4963
+ file_info -> CurrentByteOffset = cpu_to_le64 (fp -> stream .pos );
4950
4964
file_info -> Mode = fp -> coption ;
4951
4965
file_info -> AlignmentRequirement = 0 ;
4952
4966
conv_len = smbConvertToUTF16 ((__le16 * )file_info -> FileName , filename ,
@@ -5134,8 +5148,13 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,
5134
5148
time = ksmbd_UnixTimeToNT (stat .ctime );
5135
5149
file_info -> ChangeTime = cpu_to_le64 (time );
5136
5150
file_info -> Attributes = fp -> f_ci -> m_fattr ;
5137
- file_info -> AllocationSize = cpu_to_le64 (stat .blocks << 9 );
5138
- file_info -> EndOfFile = S_ISDIR (stat .mode ) ? 0 : cpu_to_le64 (stat .size );
5151
+ if (ksmbd_stream_fd (fp ) == false) {
5152
+ file_info -> AllocationSize = cpu_to_le64 (stat .blocks << 9 );
5153
+ file_info -> EndOfFile = S_ISDIR (stat .mode ) ? 0 : cpu_to_le64 (stat .size );
5154
+ } else {
5155
+ file_info -> AllocationSize = cpu_to_le64 (fp -> stream .size );
5156
+ file_info -> EndOfFile = cpu_to_le64 (fp -> stream .size );
5157
+ }
5139
5158
file_info -> Reserved = cpu_to_le32 (0 );
5140
5159
rsp -> OutputBufferLength =
5141
5160
cpu_to_le32 (sizeof (struct smb2_file_ntwrk_info ));
@@ -5158,7 +5177,11 @@ static void get_file_position_info(struct smb2_query_info_rsp *rsp,
5158
5177
struct smb2_file_pos_info * file_info ;
5159
5178
5160
5179
file_info = (struct smb2_file_pos_info * )rsp -> Buffer ;
5161
- file_info -> CurrentByteOffset = cpu_to_le64 (fp -> filp -> f_pos );
5180
+ if (ksmbd_stream_fd (fp ) == false)
5181
+ file_info -> CurrentByteOffset = cpu_to_le64 (fp -> filp -> f_pos );
5182
+ else
5183
+ file_info -> CurrentByteOffset = cpu_to_le64 (fp -> stream .pos );
5184
+
5162
5185
rsp -> OutputBufferLength =
5163
5186
cpu_to_le32 (sizeof (struct smb2_file_pos_info ));
5164
5187
}
@@ -5247,8 +5270,13 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
5247
5270
file_info -> ChangeTime = cpu_to_le64 (time );
5248
5271
file_info -> DosAttributes = fp -> f_ci -> m_fattr ;
5249
5272
file_info -> Inode = cpu_to_le64 (stat .ino );
5250
- file_info -> EndOfFile = cpu_to_le64 (stat .size );
5251
- file_info -> AllocationSize = cpu_to_le64 (stat .blocks << 9 );
5273
+ if (ksmbd_stream_fd (fp ) == false) {
5274
+ file_info -> EndOfFile = cpu_to_le64 (stat .size );
5275
+ file_info -> AllocationSize = cpu_to_le64 (stat .blocks << 9 );
5276
+ } else {
5277
+ file_info -> EndOfFile = cpu_to_le64 (fp -> stream .size );
5278
+ file_info -> AllocationSize = cpu_to_le64 (fp -> stream .size );
5279
+ }
5252
5280
file_info -> HardLinks = cpu_to_le32 (stat .nlink );
5253
5281
file_info -> Mode = cpu_to_le32 (stat .mode & 0777 );
5254
5282
switch (stat .mode & S_IFMT ) {
@@ -6190,6 +6218,9 @@ static int set_file_allocation_info(struct ksmbd_work *work,
6190
6218
if (!(fp -> daccess & FILE_WRITE_DATA_LE ))
6191
6219
return - EACCES ;
6192
6220
6221
+ if (ksmbd_stream_fd (fp ) == true)
6222
+ return 0 ;
6223
+
6193
6224
rc = vfs_getattr (& fp -> filp -> f_path , & stat , STATX_BASIC_STATS ,
6194
6225
AT_STATX_SYNC_AS_STAT );
6195
6226
if (rc )
@@ -6248,7 +6279,8 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp,
6248
6279
* truncate of some filesystem like FAT32 fill zero data in
6249
6280
* truncated range.
6250
6281
*/
6251
- if (inode -> i_sb -> s_magic != MSDOS_SUPER_MAGIC ) {
6282
+ if (inode -> i_sb -> s_magic != MSDOS_SUPER_MAGIC &&
6283
+ ksmbd_stream_fd (fp ) == false) {
6252
6284
ksmbd_debug (SMB , "truncated to newsize %lld\n" , newsize );
6253
6285
rc = ksmbd_vfs_truncate (work , fp , newsize );
6254
6286
if (rc ) {
@@ -6321,7 +6353,13 @@ static int set_file_position_info(struct ksmbd_file *fp,
6321
6353
return - EINVAL ;
6322
6354
}
6323
6355
6324
- fp -> filp -> f_pos = current_byte_offset ;
6356
+ if (ksmbd_stream_fd (fp ) == false)
6357
+ fp -> filp -> f_pos = current_byte_offset ;
6358
+ else {
6359
+ if (current_byte_offset > XATTR_SIZE_MAX )
6360
+ current_byte_offset = XATTR_SIZE_MAX ;
6361
+ fp -> stream .pos = current_byte_offset ;
6362
+ }
6325
6363
return 0 ;
6326
6364
}
6327
6365
0 commit comments