Merge tag 'v6.7-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull smb client fixes from Steve French:

- Two fallocate fixes

- Fix warnings from new gcc

- Two symlink fixes

* tag 'v6.7-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
smb: client, common: fix fortify warnings
cifs: Fix FALLOC_FL_INSERT_RANGE by setting i_size after EOF moved
cifs: Fix FALLOC_FL_ZERO_RANGE by setting i_size if EOF moved
smb: client: report correct st_size for SMB and NFS symlinks
smb: client: fix missing mode bits for SMB symlinks

Changed files
+54 -34
fs
+14 -10
fs/smb/client/cifspdu.h
··· 882 882 __u8 OplockLevel; 883 883 __u16 Fid; 884 884 __le32 CreateAction; 885 - __le64 CreationTime; 886 - __le64 LastAccessTime; 887 - __le64 LastWriteTime; 888 - __le64 ChangeTime; 889 - __le32 FileAttributes; 885 + struct_group(common_attributes, 886 + __le64 CreationTime; 887 + __le64 LastAccessTime; 888 + __le64 LastWriteTime; 889 + __le64 ChangeTime; 890 + __le32 FileAttributes; 891 + ); 890 892 __le64 AllocationSize; 891 893 __le64 EndOfFile; 892 894 __le16 FileType; ··· 2266 2264 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */ 2267 2265 /******************************************************************************/ 2268 2266 typedef struct { /* data block encoding of response to level 263 QPathInfo */ 2269 - __le64 CreationTime; 2270 - __le64 LastAccessTime; 2271 - __le64 LastWriteTime; 2272 - __le64 ChangeTime; 2273 - __le32 Attributes; 2267 + struct_group(common_attributes, 2268 + __le64 CreationTime; 2269 + __le64 LastAccessTime; 2270 + __le64 LastWriteTime; 2271 + __le64 ChangeTime; 2272 + __le32 Attributes; 2273 + ); 2274 2274 __u32 Pad1; 2275 2275 __le64 AllocationSize; 2276 2276 __le64 EndOfFile; /* size ie offset to first free byte in file */
+4 -2
fs/smb/client/cifssmb.c
··· 1244 1244 *oplock |= CIFS_CREATE_ACTION; 1245 1245 1246 1246 if (buf) { 1247 - /* copy from CreationTime to Attributes */ 1248 - memcpy((char *)buf, (char *)&rsp->CreationTime, 36); 1247 + /* copy commonly used attributes */ 1248 + memcpy(&buf->common_attributes, 1249 + &rsp->common_attributes, 1250 + sizeof(buf->common_attributes)); 1249 1251 /* the file_info buf is endian converted by caller */ 1250 1252 buf->AllocationSize = rsp->AllocationSize; 1251 1253 buf->EndOfFile = rsp->EndOfFile;
+3 -1
fs/smb/client/inode.c
··· 790 790 case 0: /* SMB1 symlink */ 791 791 case IO_REPARSE_TAG_SYMLINK: 792 792 case IO_REPARSE_TAG_NFS: 793 - fattr->cf_mode = S_IFLNK; 793 + fattr->cf_mode = S_IFLNK | cifs_sb->ctx->file_mode; 794 794 fattr->cf_dtype = DT_LNK; 795 795 break; 796 796 default: ··· 865 865 866 866 out_reparse: 867 867 if (S_ISLNK(fattr->cf_mode)) { 868 + if (likely(data->symlink_target)) 869 + fattr->cf_eof = strnlen(data->symlink_target, PATH_MAX); 868 870 fattr->cf_symlink_target = data->symlink_target; 869 871 data->symlink_target = NULL; 870 872 }
+11 -2
fs/smb/client/smb2ops.c
··· 3311 3311 struct inode *inode = file_inode(file); 3312 3312 struct cifsInodeInfo *cifsi = CIFS_I(inode); 3313 3313 struct cifsFileInfo *cfile = file->private_data; 3314 + unsigned long long new_size; 3314 3315 long rc; 3315 3316 unsigned int xid; 3316 3317 __le64 eof; ··· 3342 3341 /* 3343 3342 * do we also need to change the size of the file? 3344 3343 */ 3345 - if (keep_size == false && i_size_read(inode) < offset + len) { 3346 - eof = cpu_to_le64(offset + len); 3344 + new_size = offset + len; 3345 + if (keep_size == false && (unsigned long long)i_size_read(inode) < new_size) { 3346 + eof = cpu_to_le64(new_size); 3347 3347 rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, 3348 3348 cfile->fid.volatile_fid, cfile->pid, &eof); 3349 + if (rc >= 0) { 3350 + truncate_setsize(inode, new_size); 3351 + fscache_resize_cookie(cifs_inode_cookie(inode), new_size); 3352 + } 3349 3353 } 3350 3354 3351 3355 zero_range_exit: ··· 3744 3738 cfile->fid.volatile_fid, cfile->pid, &eof); 3745 3739 if (rc < 0) 3746 3740 goto out_2; 3741 + 3742 + truncate_setsize(inode, old_eof + len); 3743 + fscache_resize_cookie(cifs_inode_cookie(inode), i_size_read(inode)); 3747 3744 3748 3745 rc = smb2_copychunk_range(xid, cfile, cfile, off, count, off + len); 3749 3746 if (rc < 0)
+3 -5
fs/smb/client/smb2pdu.c
··· 3472 3472 } else { 3473 3473 trace_smb3_close_done(xid, persistent_fid, tcon->tid, 3474 3474 ses->Suid); 3475 - /* 3476 - * Note that have to subtract 4 since struct network_open_info 3477 - * has a final 4 byte pad that close response does not have 3478 - */ 3479 3475 if (pbuf) 3480 - memcpy(pbuf, (char *)&rsp->CreationTime, sizeof(*pbuf) - 4); 3476 + memcpy(&pbuf->network_open_info, 3477 + &rsp->network_open_info, 3478 + sizeof(pbuf->network_open_info)); 3481 3479 } 3482 3480 3483 3481 atomic_dec(&tcon->num_remote_opens);
+9 -7
fs/smb/client/smb2pdu.h
··· 319 319 } __packed; 320 320 321 321 struct smb2_file_network_open_info { 322 - __le64 CreationTime; 323 - __le64 LastAccessTime; 324 - __le64 LastWriteTime; 325 - __le64 ChangeTime; 326 - __le64 AllocationSize; 327 - __le64 EndOfFile; 328 - __le32 Attributes; 322 + struct_group(network_open_info, 323 + __le64 CreationTime; 324 + __le64 LastAccessTime; 325 + __le64 LastWriteTime; 326 + __le64 ChangeTime; 327 + __le64 AllocationSize; 328 + __le64 EndOfFile; 329 + __le32 Attributes; 330 + ); 329 331 __le32 Reserved; 330 332 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */ 331 333
+10 -7
fs/smb/common/smb2pdu.h
··· 702 702 __le16 StructureSize; /* 60 */ 703 703 __le16 Flags; 704 704 __le32 Reserved; 705 - __le64 CreationTime; 706 - __le64 LastAccessTime; 707 - __le64 LastWriteTime; 708 - __le64 ChangeTime; 709 - __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ 710 - __le64 EndOfFile; 711 - __le32 Attributes; 705 + struct_group(network_open_info, 706 + __le64 CreationTime; 707 + __le64 LastAccessTime; 708 + __le64 LastWriteTime; 709 + __le64 ChangeTime; 710 + /* Beginning of FILE_STANDARD_INFO equivalent */ 711 + __le64 AllocationSize; 712 + __le64 EndOfFile; 713 + __le32 Attributes; 714 + ); 712 715 } __packed; 713 716 714 717