Skip to contentSkip to conversation

cifs: fix handle leak in smb2_query_symlink()

PATCH In review Ronnie Sahlberg 2 participants 2 messages Apr 9, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: fix handle leak in smb2_query_symlink()

If we enter smb2_query_symlink() for something that is not a symlink and where the SMB2_open() would succeed we would never end up closing this handle and would thus leak a handle on the server.

Fix this by immediately calling SMB2_close() on successfull open.

---
 fs/cifs/smb2ops.c | 2 ++
 1 file changed, 2 insertions(+)
fs/cifs/smb2ops.c +2 -0
index 83a100dd2497..ab4737e3c31f 100644
@@ -2397,6 +2397,8 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
 
 	rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_iov,
 		       &resp_buftype);
+	if (!rc)
+		SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
 	if (!rc || !err_iov.iov_base) {
 		rc = -ENOENT;
 		goto free_path;
Signature · 1 line
2.13.6
Reviewed-by on v1 1/1
#1 lore raw

вт, 9 апр. 2019 г. в 14:47, Ronnie Sahlberg <[email protected]>:

Quoted 27 lines

If we enter smb2_query_symlink() for something that is not a symlink and where the SMB2_open() would succeed we would never end up closing this handle and would thus leak a handle on the server.

Fix this by immediately calling SMB2_close() on successfull open.

---
 fs/cifs/smb2ops.c | 2 ++
 1 file changed, 2 insertions(+)
fs/cifs/smb2ops.c +2 -1
index 83a100dd2497..ab4737e3c31f 100644
@@ -2397,6 +2397,8 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
 
        rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_iov,
                       &resp_buftype);
+       if (!rc)
+               SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
        if (!rc || !err_iov.iov_base) {
                rc = -ENOENT;
                goto free_path;
--
Quoted 2 lines

2.13.6

Looks good.

--
Best regards,
Pavel Shilovsky