smb: client: fix potential UAF and double free it smb2_open_file()
Subsystems (2)
Paulo Alcantara
maintainerPATCH 1/1 smb: client: fix potential UAF and double free it smb2_open_file()
Zero out @err_iov and @err_buftype before retrying SMB2_open() to prevent an UAF bug if @data != NULL, otherwise a double free.
--- fs/smb/client/smb2file.c | 2 ++ 1 file changed, 2 insertions(+)
fs/smb/client/smb2file.c +2 -0
@@ -179,6 +179,8 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, &err_buftype);if (rc == -EACCES && retry_without_read_attributes) {free_rsp_buf (err_buftype, err_iov.iov_base); +memset (&err_iov,0 ,sizeof (err_iov)); + err_buftype =CIFS_NO_BUFFER ; oparms->desired_access &= ~FILE_READ_ATTRIBUTES ; rc =SMB2_open (xid, oparms, smb2_path, &smb2_oplock, smb2_data,NULL , &err_iov, &err_buftype);
Signature · 1 line
2.52.0
Looks good. Feel free to add:
Quoted 27 lines · Paulo Alcantara
Zero out @err_iov and @err_buftype before retrying
SMB2_open()to prevent an UAF bug if @data != NULL, otherwise a double free.Fixes e3a43633023e ("smb/client: fix memory leak in smb2_open_file()")Reported-by David Howells <[email protected]>Signed-off-by Paulo Alcantara (Red Hat) <[email protected]>Reviewed-by David Howells <[email protected]>Cc ChenXiaoSong <[email protected]>--- fs/smb/client/smb2file.c | 2 ++ 1 file changed, 2 insertions(+)fs/smb/client/smb2file.c +2
-0@@ -179,6 +179,8 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, &err_buftype);if (rc == -EACCES && retry_without_read_attributes) {free_rsp_buf (err_buftype, err_iov.iov_base); +memset (&err_iov,0 ,sizeof (err_iov)); + err_buftype =CIFS_NO_BUFFER ; oparms->desired_access &= ~FILE_READ_ATTRIBUTES ; rc =SMB2_open (xid, oparms, smb2_path, &smb2_oplock, smb2_data,NULL , &err_iov, &err_buftype);
Is there a typo in the subject? Should it be "in ..." instead of "it ..."?
Thanks,
ChenXiaoSong <[email protected]>
Quoted 1 line · Paulo Alcantara
[PATCH] smb: client: fix potential UAF and double free it
smb2_open_file()
Quoted 2 lines · ChenXiaoSong
Is there a typo in the subject? Should it be "in ..." instead of "it ..."?
Yes - I will fix the typo
Quoted 6 lines
Thanks,
ChenXiaoSong <[email protected]>Quoted 1 line · Paulo Alcantara
[PATCH] smb: client: fix potential UAF and double free it
smb2_open_file()
Signature · 3 lines
Thanks, Steve
corrected typo and added Chen's Reviewed-by and merged into cifs-2.6.git for-next
Quoted 31 lines · Paulo Alcantara
Zero out @err_iov and @err_buftype before retrying
SMB2_open()to prevent an UAF bug if @data != NULL, otherwise a double free.Fixes e3a43633023e ("smb/client: fix memory leak in smb2_open_file()")Reported-by David Howells <[email protected]>Signed-off-by Paulo Alcantara (Red Hat) <[email protected]>Reviewed-by David Howells <[email protected]>Cc ChenXiaoSong <[email protected]>--- fs/smb/client/smb2file.c | 2 ++ 1 file changed, 2 insertions(+)fs/smb/client/smb2file.c +2
-1@@ -179,6 +179,8 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, &err_buftype);if (rc == -EACCES && retry_without_read_attributes) {free_rsp_buf (err_buftype, err_iov.iov_base); +memset (&err_iov,0 ,sizeof (err_iov)); + err_buftype =CIFS_NO_BUFFER ; oparms->desired_access &= ~FILE_READ_ATTRIBUTES ; rc =SMB2_open (xid, oparms, smb2_path, &smb2_oplock, smb2_data,NULL , &err_iov, &err_buftype); --2.52.0
Signature · 3 lines
Thanks, Steve