Skip to content

Commit 968f35f

Browse files
committed
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
2 parents 55abae4 + 0015eb6 commit 968f35f

File tree

7 files changed

+54
-34
lines changed

7 files changed

+54
-34
lines changed

fs/smb/client/cifspdu.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -882,11 +882,13 @@ typedef struct smb_com_open_rsp {
882882
__u8 OplockLevel;
883883
__u16 Fid;
884884
__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+
);
890892
__le64 AllocationSize;
891893
__le64 EndOfFile;
892894
__le16 FileType;
@@ -2264,11 +2266,13 @@ typedef struct {
22642266
/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
22652267
/******************************************************************************/
22662268
typedef struct { /* data block encoding of response to level 263 QPathInfo */
2267-
__le64 CreationTime;
2268-
__le64 LastAccessTime;
2269-
__le64 LastWriteTime;
2270-
__le64 ChangeTime;
2271-
__le32 Attributes;
2269+
struct_group(common_attributes,
2270+
__le64 CreationTime;
2271+
__le64 LastAccessTime;
2272+
__le64 LastWriteTime;
2273+
__le64 ChangeTime;
2274+
__le32 Attributes;
2275+
);
22722276
__u32 Pad1;
22732277
__le64 AllocationSize;
22742278
__le64 EndOfFile; /* size ie offset to first free byte in file */

fs/smb/client/cifssmb.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,10 @@ CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock,
12441244
*oplock |= CIFS_CREATE_ACTION;
12451245

12461246
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));
12491251
/* the file_info buf is endian converted by caller */
12501252
buf->AllocationSize = rsp->AllocationSize;
12511253
buf->EndOfFile = rsp->EndOfFile;

fs/smb/client/inode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb,
790790
case 0: /* SMB1 symlink */
791791
case IO_REPARSE_TAG_SYMLINK:
792792
case IO_REPARSE_TAG_NFS:
793-
fattr->cf_mode = S_IFLNK;
793+
fattr->cf_mode = S_IFLNK | cifs_sb->ctx->file_mode;
794794
fattr->cf_dtype = DT_LNK;
795795
break;
796796
default:
@@ -865,6 +865,8 @@ static void cifs_open_info_to_fattr(struct cifs_fattr *fattr,
865865

866866
out_reparse:
867867
if (S_ISLNK(fattr->cf_mode)) {
868+
if (likely(data->symlink_target))
869+
fattr->cf_eof = strnlen(data->symlink_target, PATH_MAX);
868870
fattr->cf_symlink_target = data->symlink_target;
869871
data->symlink_target = NULL;
870872
}

fs/smb/client/smb2ops.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3311,6 +3311,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
33113311
struct inode *inode = file_inode(file);
33123312
struct cifsInodeInfo *cifsi = CIFS_I(inode);
33133313
struct cifsFileInfo *cfile = file->private_data;
3314+
unsigned long long new_size;
33143315
long rc;
33153316
unsigned int xid;
33163317
__le64 eof;
@@ -3341,10 +3342,15 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
33413342
/*
33423343
* do we also need to change the size of the file?
33433344
*/
3344-
if (keep_size == false && i_size_read(inode) < offset + len) {
3345-
eof = cpu_to_le64(offset + len);
3345+
new_size = offset + len;
3346+
if (keep_size == false && (unsigned long long)i_size_read(inode) < new_size) {
3347+
eof = cpu_to_le64(new_size);
33463348
rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
33473349
cfile->fid.volatile_fid, cfile->pid, &eof);
3350+
if (rc >= 0) {
3351+
truncate_setsize(inode, new_size);
3352+
fscache_resize_cookie(cifs_inode_cookie(inode), new_size);
3353+
}
33483354
}
33493355

33503356
zero_range_exit:
@@ -3739,6 +3745,9 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon,
37393745
if (rc < 0)
37403746
goto out_2;
37413747

3748+
truncate_setsize(inode, old_eof + len);
3749+
fscache_resize_cookie(cifs_inode_cookie(inode), i_size_read(inode));
3750+
37423751
rc = smb2_copychunk_range(xid, cfile, cfile, off, count, off + len);
37433752
if (rc < 0)
37443753
goto out_2;

fs/smb/client/smb2pdu.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3472,12 +3472,10 @@ __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
34723472
} else {
34733473
trace_smb3_close_done(xid, persistent_fid, tcon->tid,
34743474
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-
*/
34793475
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));
34813479
}
34823480

34833481
atomic_dec(&tcon->num_remote_opens);

fs/smb/client/smb2pdu.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,15 @@ struct smb2_file_reparse_point_info {
319319
} __packed;
320320

321321
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+
);
329331
__le32 Reserved;
330332
} __packed; /* level 34 Query also similar returned in close rsp and open rsp */
331333

fs/smb/common/smb2pdu.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -702,13 +702,16 @@ struct smb2_close_rsp {
702702
__le16 StructureSize; /* 60 */
703703
__le16 Flags;
704704
__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+
);
712715
} __packed;
713716

714717

0 commit comments

Comments
 (0)