From: Bart Van Assche <bart.vanassche@wdc.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Doug Ledford <dledford@redhat.com>,
linux-rdma@vger.kernel.org,
Bart Van Assche <bart.vanassche@wdc.com>,
stable@vger.kernel.org
Subject: [PATCH 3/3] IB/srpt: Fix a use-after-free
Date: Tue, 10 Jul 2018 10:32:00 -0700 [thread overview]
Message-ID: <20180710173200.19853-4-bart.vanassche@wdc.com> (raw)
In-Reply-To: <20180710173200.19853-1-bart.vanassche@wdc.com>
Make sure that channel objects continue to exist until the target
core has called the .close_session() callback function. This patch
voids that KASAN sporadically reports the following:
BUG: KASAN: use-after-free in do_raw_spin_lock+0x1c/0x130
Read of size 4 at addr ffff8801534b16e4 by task rmdir/14805
CPU: 16 PID: 14805 Comm: rmdir Not tainted 4.18.0-rc2-dbg+ #5
Call Trace:
dump_stack+0xa4/0xf5
print_address_description+0x6f/0x270
kasan_report+0x241/0x360
__asan_load4+0x78/0x80
do_raw_spin_lock+0x1c/0x130
_raw_spin_lock_irqsave+0x52/0x60
srpt_set_ch_state+0x27/0x70 [ib_srpt]
srpt_disconnect_ch+0x1b/0xc0 [ib_srpt]
srpt_close_session+0xa8/0x260 [ib_srpt]
target_shutdown_sessions+0x170/0x180 [target_core_mod]
core_tpg_del_initiator_node_acl+0xf3/0x200 [target_core_mod]
target_fabric_nacl_base_release+0x25/0x30 [target_core_mod]
config_item_release+0x9c/0x110 [configfs]
config_item_put+0x26/0x30 [configfs]
configfs_rmdir+0x3b8/0x510 [configfs]
vfs_rmdir+0xb3/0x1e0
do_rmdir+0x262/0x2c0
do_syscall_64+0x77/0x230
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: <stable@vger.kernel.org>
---
drivers/infiniband/ulp/srpt/ib_srpt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 325bae29e90d..705f6a992d82 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2152,6 +2152,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
}
kref_init(&ch->kref);
+ kref_get(&ch->kref);
ch->pkey = be16_to_cpu(pkey);
ch->nexus = nexus;
ch->zw_cqe.done = srpt_zerolength_write_done;
@@ -3212,6 +3213,7 @@ static void srpt_close_session(struct se_session *se_sess)
struct srpt_rdma_ch *ch = se_sess->fabric_sess_ptr;
srpt_disconnect_ch_sync(ch);
+ kref_put(&ch->kref, srpt_free_ch);
}
/**
--
2.18.0
next prev parent reply other threads:[~2018-07-10 17:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180710173200.19853-1-bart.vanassche@wdc.com>
2018-07-10 17:31 ` [PATCH 1/3] IB/srpt: Fix srpt_cm_req_recv() error path (1/2) Bart Van Assche
2018-07-10 17:31 ` [PATCH 2/3] IB/srpt: Fix srpt_cm_req_recv() error path (2/2) Bart Van Assche
2018-07-10 17:32 ` Bart Van Assche [this message]
2018-07-10 18:38 ` [PATCH 3/3] IB/srpt: Fix a use-after-free Jason Gunthorpe
2018-07-10 20:19 ` Bart Van Assche
2018-07-10 21:36 ` Jason Gunthorpe
2018-07-10 18:51 ` Greg KH
2018-07-10 20:23 ` Bart Van Assche
2018-07-10 20:44 ` gregkh
2018-07-10 21:02 ` Bart Van Assche
2018-07-11 9:45 ` gregkh
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=20180710173200.19853-4-bart.vanassche@wdc.com \
--to=bart.vanassche@wdc.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=linux-rdma@vger.kernel.org \
--cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox