cifs: fix handle leak in smb2_query_symlink()
Subsystems (3)
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.
Signed-off-by Ronnie Sahlberg <[email protected]>
CC Stable <[email protected]>
--- fs/cifs/smb2ops.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/smb2ops.c +2 -0
@@ -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
вт, 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 theSMB2_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.Signed-off-by Ronnie Sahlberg <[email protected]>CC Stable <[email protected]>--- fs/cifs/smb2ops.c | 2 ++ 1 file changed, 2 insertions(+)fs/cifs/smb2ops.c +2
-1@@ -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.
Reviewed-by Pavel Shilovsky <[email protected]>
--
Best regards,
Pavel Shilovsky