diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-08-25 20:22:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-08-25 20:22:33 -0400 |
commit | 8c7932a32e1ebf6e845bd32a5399cce442d2e745 (patch) | |
tree | e517d964fff8029ab306c5587d8da5ad368ebc07 | |
parent | d580e80c7f2ffb8f86e2417495692ce8bcc91dad (diff) | |
parent | d3edede29f74d335f81d95a4588f5f136a9f7dcf (diff) |
Merge tag 'cifs-fixes-for-4.13-rc6-and-stable' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French:
"Some bug fixes for stable for cifs"
* tag 'cifs-fixes-for-4.13-rc6-and-stable' of git://git.samba.org/sfrench/cifs-2.6:
cifs: return ENAMETOOLONG for overlong names in cifs_open()/cifs_lookup()
cifs: Fix df output for users with quota limits
-rw-r--r-- | fs/cifs/dir.c | 18 | ||||
-rw-r--r-- | fs/cifs/smb2pdu.c | 4 |
2 files changed, 14 insertions, 8 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 56366e984076..569d3fb736be 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -194,15 +194,20 @@ cifs_bp_rename_retry: | |||
194 | } | 194 | } |
195 | 195 | ||
196 | /* | 196 | /* |
197 | * Don't allow path components longer than the server max. | ||
197 | * Don't allow the separator character in a path component. | 198 | * Don't allow the separator character in a path component. |
198 | * The VFS will not allow "/", but "\" is allowed by posix. | 199 | * The VFS will not allow "/", but "\" is allowed by posix. |
199 | */ | 200 | */ |
200 | static int | 201 | static int |
201 | check_name(struct dentry *direntry) | 202 | check_name(struct dentry *direntry, struct cifs_tcon *tcon) |
202 | { | 203 | { |
203 | struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); | 204 | struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); |
204 | int i; | 205 | int i; |
205 | 206 | ||
207 | if (unlikely(direntry->d_name.len > | ||
208 | tcon->fsAttrInfo.MaxPathNameComponentLength)) | ||
209 | return -ENAMETOOLONG; | ||
210 | |||
206 | if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) { | 211 | if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) { |
207 | for (i = 0; i < direntry->d_name.len; i++) { | 212 | for (i = 0; i < direntry->d_name.len; i++) { |
208 | if (direntry->d_name.name[i] == '\\') { | 213 | if (direntry->d_name.name[i] == '\\') { |
@@ -500,10 +505,6 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, | |||
500 | return finish_no_open(file, res); | 505 | return finish_no_open(file, res); |
501 | } | 506 | } |
502 | 507 | ||
503 | rc = check_name(direntry); | ||
504 | if (rc) | ||
505 | return rc; | ||
506 | |||
507 | xid = get_xid(); | 508 | xid = get_xid(); |
508 | 509 | ||
509 | cifs_dbg(FYI, "parent inode = 0x%p name is: %pd and dentry = 0x%p\n", | 510 | cifs_dbg(FYI, "parent inode = 0x%p name is: %pd and dentry = 0x%p\n", |
@@ -516,6 +517,11 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, | |||
516 | } | 517 | } |
517 | 518 | ||
518 | tcon = tlink_tcon(tlink); | 519 | tcon = tlink_tcon(tlink); |
520 | |||
521 | rc = check_name(direntry, tcon); | ||
522 | if (rc) | ||
523 | goto out_free_xid; | ||
524 | |||
519 | server = tcon->ses->server; | 525 | server = tcon->ses->server; |
520 | 526 | ||
521 | if (server->ops->new_lease_key) | 527 | if (server->ops->new_lease_key) |
@@ -776,7 +782,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, | |||
776 | } | 782 | } |
777 | pTcon = tlink_tcon(tlink); | 783 | pTcon = tlink_tcon(tlink); |
778 | 784 | ||
779 | rc = check_name(direntry); | 785 | rc = check_name(direntry, pTcon); |
780 | if (rc) | 786 | if (rc) |
781 | goto lookup_out; | 787 | goto lookup_out; |
782 | 788 | ||
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 5fb2fc2d0080..97edb4d376cd 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
@@ -3219,8 +3219,8 @@ copy_fs_info_to_kstatfs(struct smb2_fs_full_size_info *pfs_inf, | |||
3219 | kst->f_bsize = le32_to_cpu(pfs_inf->BytesPerSector) * | 3219 | kst->f_bsize = le32_to_cpu(pfs_inf->BytesPerSector) * |
3220 | le32_to_cpu(pfs_inf->SectorsPerAllocationUnit); | 3220 | le32_to_cpu(pfs_inf->SectorsPerAllocationUnit); |
3221 | kst->f_blocks = le64_to_cpu(pfs_inf->TotalAllocationUnits); | 3221 | kst->f_blocks = le64_to_cpu(pfs_inf->TotalAllocationUnits); |
3222 | kst->f_bfree = le64_to_cpu(pfs_inf->ActualAvailableAllocationUnits); | 3222 | kst->f_bfree = kst->f_bavail = |
3223 | kst->f_bavail = le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits); | 3223 | le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits); |
3224 | return; | 3224 | return; |
3225 | } | 3225 | } |
3226 | 3226 | ||