Skip to content

Commit d2f1542

Browse files
committed
smb3: fix leak in "open on server" perf counter
We were not bumping up the "open on server" (num_remote_opens) counter (in some cases) on opens of the share root so could end up showing as a negative value. CC: Stable <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]>
1 parent 7e7db86 commit d2f1542

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

fs/cifs/smb2ops.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid)
751751
goto oshr_exit;
752752
}
753753

754+
atomic_inc(&tcon->num_remote_opens);
755+
754756
o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base;
755757
oparms.fid->persistent_fid = o_rsp->PersistentFileId;
756758
oparms.fid->volatile_fid = o_rsp->VolatileFileId;
@@ -1176,6 +1178,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
11761178

11771179
rc = compound_send_recv(xid, ses, flags, 3, rqst,
11781180
resp_buftype, rsp_iov);
1181+
/* no need to bump num_remote_opens because handle immediately closed */
11791182

11801183
sea_exit:
11811184
kfree(ea);
@@ -1518,6 +1521,8 @@ smb2_ioctl_query_info(const unsigned int xid,
15181521
resp_buftype, rsp_iov);
15191522
if (rc)
15201523
goto iqinf_exit;
1524+
1525+
/* No need to bump num_remote_opens since handle immediately closed */
15211526
if (qi.flags & PASSTHRU_FSCTL) {
15221527
pqi = (struct smb_query_info __user *)arg;
15231528
io_rsp = (struct smb2_ioctl_rsp *)rsp_iov[1].iov_base;

fs/cifs/smb2pdu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,6 +2352,7 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
23522352
rqst.rq_iov = iov;
23532353
rqst.rq_nvec = n_iov;
23542354

2355+
/* no need to inc num_remote_opens because we close it just below */
23552356
trace_smb3_posix_mkdir_enter(xid, tcon->tid, ses->Suid, CREATE_NOT_FILE,
23562357
FILE_WRITE_ATTRIBUTES);
23572358
/* resource #4: response buffer */

0 commit comments

Comments
 (0)