Skip to content

Commit 5ab39e0

Browse files
committed
Merge tag '5.8-rc4-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "Four cifs/smb3 fixes: the three for stable fix problems found recently with change notification including a reference count leak" * tag '5.8-rc4-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6: cifs: update internal module version number cifs: fix reference leak for tlink smb3: fix unneeded error message on change notify cifs: remove the retry in cifs_poxis_lock_set smb3: fix access denied on change notify request to some servers
2 parents 49decdd + a8dab63 commit 5ab39e0

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

fs/cifs/cifsfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,5 @@ extern int cifs_truncate_page(struct address_space *mapping, loff_t from);
156156
extern const struct export_operations cifs_export_ops;
157157
#endif /* CONFIG_CIFS_NFSD_EXPORT */
158158

159-
#define CIFS_VERSION "2.27"
159+
#define CIFS_VERSION "2.28"
160160
#endif /* _CIFSFS_H */

fs/cifs/file.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,20 +1149,20 @@ cifs_posix_lock_test(struct file *file, struct file_lock *flock)
11491149

11501150
/*
11511151
* Set the byte-range lock (posix style). Returns:
1152-
* 1) 0, if we set the lock and don't need to request to the server;
1153-
* 2) 1, if we need to request to the server;
1154-
* 3) <0, if the error occurs while setting the lock.
1152+
* 1) <0, if the error occurs while setting the lock;
1153+
* 2) 0, if we set the lock and don't need to request to the server;
1154+
* 3) FILE_LOCK_DEFERRED, if we will wait for some other file_lock;
1155+
* 4) FILE_LOCK_DEFERRED + 1, if we need to request to the server.
11551156
*/
11561157
static int
11571158
cifs_posix_lock_set(struct file *file, struct file_lock *flock)
11581159
{
11591160
struct cifsInodeInfo *cinode = CIFS_I(file_inode(file));
1160-
int rc = 1;
1161+
int rc = FILE_LOCK_DEFERRED + 1;
11611162

11621163
if ((flock->fl_flags & FL_POSIX) == 0)
11631164
return rc;
11641165

1165-
try_again:
11661166
cifs_down_write(&cinode->lock_sem);
11671167
if (!cinode->can_cache_brlcks) {
11681168
up_write(&cinode->lock_sem);
@@ -1171,13 +1171,6 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)
11711171

11721172
rc = posix_lock_file(file, flock, NULL);
11731173
up_write(&cinode->lock_sem);
1174-
if (rc == FILE_LOCK_DEFERRED) {
1175-
rc = wait_event_interruptible(flock->fl_wait,
1176-
list_empty(&flock->fl_blocked_member));
1177-
if (!rc)
1178-
goto try_again;
1179-
locks_delete_block(flock);
1180-
}
11811174
return rc;
11821175
}
11831176

@@ -1652,7 +1645,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
16521645
int posix_lock_type;
16531646

16541647
rc = cifs_posix_lock_set(file, flock);
1655-
if (!rc || rc < 0)
1648+
if (rc <= FILE_LOCK_DEFERRED)
16561649
return rc;
16571650

16581651
if (type & server->vals->shared_lock_type)

fs/cifs/ioctl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
169169
unsigned int xid;
170170
struct cifsFileInfo *pSMBFile = filep->private_data;
171171
struct cifs_tcon *tcon;
172+
struct tcon_link *tlink;
172173
struct cifs_sb_info *cifs_sb;
173174
__u64 ExtAttrBits = 0;
174175
__u64 caps;
@@ -307,13 +308,19 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
307308
break;
308309
}
309310
cifs_sb = CIFS_SB(inode->i_sb);
310-
tcon = tlink_tcon(cifs_sb_tlink(cifs_sb));
311+
tlink = cifs_sb_tlink(cifs_sb);
312+
if (IS_ERR(tlink)) {
313+
rc = PTR_ERR(tlink);
314+
break;
315+
}
316+
tcon = tlink_tcon(tlink);
311317
if (tcon && tcon->ses->server->ops->notify) {
312318
rc = tcon->ses->server->ops->notify(xid,
313319
filep, (void __user *)arg);
314320
cifs_dbg(FYI, "ioctl notify rc %d\n", rc);
315321
} else
316322
rc = -EOPNOTSUPP;
323+
cifs_put_tlink(tlink);
317324
break;
318325
default:
319326
cifs_dbg(FYI, "unsupported ioctl\n");

fs/cifs/smb2misc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,13 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_sync_hdr *shdr)
354354
((struct smb2_ioctl_rsp *)shdr)->OutputCount);
355355
break;
356356
case SMB2_CHANGE_NOTIFY:
357+
*off = le16_to_cpu(
358+
((struct smb2_change_notify_rsp *)shdr)->OutputBufferOffset);
359+
*len = le32_to_cpu(
360+
((struct smb2_change_notify_rsp *)shdr)->OutputBufferLength);
361+
break;
357362
default:
358-
/* BB FIXME for unimplemented cases above */
359-
cifs_dbg(VFS, "no length check for command\n");
363+
cifs_dbg(VFS, "no length check for command %d\n", le16_to_cpu(shdr->Command));
360364
break;
361365
}
362366

fs/cifs/smb2ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ smb3_notify(const unsigned int xid, struct file *pfile,
21482148

21492149
tcon = cifs_sb_master_tcon(cifs_sb);
21502150
oparms.tcon = tcon;
2151-
oparms.desired_access = FILE_READ_ATTRIBUTES;
2151+
oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
21522152
oparms.disposition = FILE_OPEN;
21532153
oparms.create_options = cifs_create_options(cifs_sb, 0);
21542154
oparms.fid = &fid;

0 commit comments

Comments
 (0)