All of lore.kernel.org
 help / color / mirror / Atom feed
From: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
To: <linux-cifs@vger.kernel.org>, <sfrench@samba.org>,
	<samba-technical@lists.samba.org>, <zhangxiaoxu5@huawei.com>
Subject: [PATCH v2 1/2] cifs: Fix use-after-free in SMB2_write
Date: Sat, 6 Apr 2019 15:47:38 +0800	[thread overview]
Message-ID: <1554536859-139778-2-git-send-email-zhangxiaoxu5@huawei.com> (raw)
In-Reply-To: <1554536859-139778-1-git-send-email-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)

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 21ac19f..6cf4e88 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -3752,7 +3752,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) {
@@ -3770,6 +3769,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


  reply	other threads:[~2019-04-06  7:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-06  7:47 [PATCH v2 0/2] Fix KASAN use-after free in SMB2_write and SMB2_read ZhangXiaoxu
2019-04-06  7:47 ` ZhangXiaoxu [this message]
2019-04-07  3:28   ` [PATCH v2 1/2] cifs: Fix use-after-free in SMB2_write Steve French
2019-04-06  7:47 ` [PATCH v2 2/2] cifs: Fix use-after-free in SMB2_read ZhangXiaoxu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1554536859-139778-2-git-send-email-zhangxiaoxu5@huawei.com \
    --to=zhangxiaoxu5@huawei.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.