linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Fix KASAN use-after free in SMB2_write and SMB2_read
@ 2019-04-08  2:22 ZhangXiaoxu
  2019-04-08  2:22 ` [PATCH v3 1/2] cifs: Fix use-after-free in SMB2_write ZhangXiaoxu
  2019-04-08  2:22 ` [PATCH v3 2/2] cifs: Fix use-after-free in SMB2_read ZhangXiaoxu
  0 siblings, 2 replies; 5+ messages in thread
From: ZhangXiaoxu @ 2019-04-08  2:22 UTC (permalink / raw)
  To: linux-cifs, sfrench, samba-technical, zhangxiaoxu5

v2->v3: add cc: stable@vger.kernel.org (v4.18+)
v1->v2: Add Fixes: eccb4422cf97(smb3: Add ftrace tracepoints for improved SMB3 debugging)

ZhangXiaoxu (2):
  cifs: Fix use-after-free in SMB2_write
  cifs: Fix use-after-free in SMB2_read

 fs/cifs/smb2pdu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/2] cifs: Fix use-after-free in SMB2_write
  2019-04-08  2:22 [PATCH v3 0/2] Fix KASAN use-after free in SMB2_write and SMB2_read ZhangXiaoxu
@ 2019-04-08  2:22 ` ZhangXiaoxu
  2019-04-08 23:09   ` Pavel Shilovsky
  2019-04-08  2:22 ` [PATCH v3 2/2] cifs: Fix use-after-free in SMB2_read ZhangXiaoxu
  1 sibling, 1 reply; 5+ messages in thread
From: ZhangXiaoxu @ 2019-04-08  2:22 UTC (permalink / raw)
  To: linux-cifs, sfrench, samba-technical, zhangxiaoxu5

There is a KASAN use-after-free:
BUG: KASAN: use-after-free in SMB2_write+0x1342/0x1580
Read of size 8 at addr ffff8880b6a8e450 by task ln/4196

Should not release the 'req' because it will use in the trace.

Fixes: eccb4422cf97(smb3: Add ftrace tracepoints for improved SMB3 debugging)

cc: stable@vger.kernel.org (v4.18+)
Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
---
 fs/cifs/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 0f14471..fca5b0a 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -3772,7 +3772,6 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
 
 	rc = cifs_send_recv(xid, io_parms->tcon->ses, &rqst,
 			    &resp_buftype, flags, &rsp_iov);
-	cifs_small_buf_release(req);
 	rsp = (struct smb2_write_rsp *)rsp_iov.iov_base;
 
 	if (rc) {
@@ -3790,6 +3789,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
 				     io_parms->offset, *nbytes);
 	}
 
+	cifs_small_buf_release(req);
 	free_rsp_buf(resp_buftype, rsp);
 	return rc;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/2] cifs: Fix use-after-free in SMB2_read
  2019-04-08  2:22 [PATCH v3 0/2] Fix KASAN use-after free in SMB2_write and SMB2_read ZhangXiaoxu
  2019-04-08  2:22 ` [PATCH v3 1/2] cifs: Fix use-after-free in SMB2_write ZhangXiaoxu
@ 2019-04-08  2:22 ` ZhangXiaoxu
  2019-04-08 23:09   ` Pavel Shilovsky
  1 sibling, 1 reply; 5+ messages in thread
From: ZhangXiaoxu @ 2019-04-08  2:22 UTC (permalink / raw)
  To: linux-cifs, sfrench, samba-technical, zhangxiaoxu5

There is a KASAN use-after-free:
BUG: KASAN: use-after-free in SMB2_read+0x1136/0x1190
Read of size 8 at addr ffff8880b4e45e50 by task ln/1009

Should not release the 'req' because it will use in the trace.

Fixes: eccb4422cf97(smb3: Add ftrace tracepoints for improved SMB3 debugging)

cc: stable@vger.kernel.org (v4.18+)
Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
---
 fs/cifs/smb2pdu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index fca5b0a..b8f7262 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -3451,8 +3451,6 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
 	rqst.rq_nvec = 1;
 
 	rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
-	cifs_small_buf_release(req);
-
 	rsp = (struct smb2_read_rsp *)rsp_iov.iov_base;
 
 	if (rc) {
@@ -3474,6 +3472,8 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
 				    io_parms->tcon->tid, ses->Suid,
 				    io_parms->offset, io_parms->length);
 
+	cifs_small_buf_release(req);
+
 	*nbytes = le32_to_cpu(rsp->DataLength);
 	if ((*nbytes > CIFS_MAX_MSGSIZE) ||
 	    (*nbytes > io_parms->length)) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 1/2] cifs: Fix use-after-free in SMB2_write
  2019-04-08  2:22 ` [PATCH v3 1/2] cifs: Fix use-after-free in SMB2_write ZhangXiaoxu
@ 2019-04-08 23:09   ` Pavel Shilovsky
  0 siblings, 0 replies; 5+ messages in thread
From: Pavel Shilovsky @ 2019-04-08 23:09 UTC (permalink / raw)
  To: ZhangXiaoxu; +Cc: linux-cifs, Steve French, samba-technical

вс, 7 апр. 2019 г. в 19:18, ZhangXiaoxu <zhangxiaoxu5@huawei.com>:
>
> There is a KASAN use-after-free:
> BUG: KASAN: use-after-free in SMB2_write+0x1342/0x1580
> Read of size 8 at addr ffff8880b6a8e450 by task ln/4196
>
> Should not release the 'req' because it will use in the trace.
>
> Fixes: eccb4422cf97(smb3: Add ftrace tracepoints for improved SMB3 debugging)
>
> cc: stable@vger.kernel.org (v4.18+)
> Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
> ---
>  fs/cifs/smb2pdu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 0f14471..fca5b0a 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -3772,7 +3772,6 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
>
>         rc = cifs_send_recv(xid, io_parms->tcon->ses, &rqst,
>                             &resp_buftype, flags, &rsp_iov);
> -       cifs_small_buf_release(req);
>         rsp = (struct smb2_write_rsp *)rsp_iov.iov_base;
>
>         if (rc) {
> @@ -3790,6 +3789,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
>                                      io_parms->offset, *nbytes);
>         }
>
> +       cifs_small_buf_release(req);
>         free_rsp_buf(resp_buftype, rsp);
>         return rc;
>  }
> --
> 2.7.4
>

Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>

--
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 2/2] cifs: Fix use-after-free in SMB2_read
  2019-04-08  2:22 ` [PATCH v3 2/2] cifs: Fix use-after-free in SMB2_read ZhangXiaoxu
@ 2019-04-08 23:09   ` Pavel Shilovsky
  0 siblings, 0 replies; 5+ messages in thread
From: Pavel Shilovsky @ 2019-04-08 23:09 UTC (permalink / raw)
  To: ZhangXiaoxu; +Cc: linux-cifs, Steve French, samba-technical

вс, 7 апр. 2019 г. в 19:18, ZhangXiaoxu <zhangxiaoxu5@huawei.com>:
>
> There is a KASAN use-after-free:
> BUG: KASAN: use-after-free in SMB2_read+0x1136/0x1190
> Read of size 8 at addr ffff8880b4e45e50 by task ln/1009
>
> Should not release the 'req' because it will use in the trace.
>
> Fixes: eccb4422cf97(smb3: Add ftrace tracepoints for improved SMB3 debugging)
>
> cc: stable@vger.kernel.org (v4.18+)
> Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
> ---
>  fs/cifs/smb2pdu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index fca5b0a..b8f7262 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -3451,8 +3451,6 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
>         rqst.rq_nvec = 1;
>
>         rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
> -       cifs_small_buf_release(req);
> -
>         rsp = (struct smb2_read_rsp *)rsp_iov.iov_base;
>
>         if (rc) {
> @@ -3474,6 +3472,8 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
>                                     io_parms->tcon->tid, ses->Suid,
>                                     io_parms->offset, io_parms->length);
>
> +       cifs_small_buf_release(req);
> +
>         *nbytes = le32_to_cpu(rsp->DataLength);
>         if ((*nbytes > CIFS_MAX_MSGSIZE) ||
>             (*nbytes > io_parms->length)) {
> --
> 2.7.4
>

Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>

--
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-08 23:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08  2:22 [PATCH v3 0/2] Fix KASAN use-after free in SMB2_write and SMB2_read ZhangXiaoxu
2019-04-08  2:22 ` [PATCH v3 1/2] cifs: Fix use-after-free in SMB2_write ZhangXiaoxu
2019-04-08 23:09   ` Pavel Shilovsky
2019-04-08  2:22 ` [PATCH v3 2/2] cifs: Fix use-after-free in SMB2_read ZhangXiaoxu
2019-04-08 23:09   ` Pavel Shilovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).