From: Jason Gunthorpe <jgg@ziepe.ca>
To: Hillf Danton <hdanton@sina.com>
Cc: syzbot <syzbot+57a3b121df74c4eccbc7@syzkaller.appspotmail.com>,
bvanassche@acm.org, danitg@mellanox.com, dledford@redhat.com,
leon@kernel.org, linux-kernel@vger.kernel.org,
linux-rdma@vger.kernel.org, mhjungk@gmail.com,
parav@mellanox.com, shamir.rabinovitch@oracle.com,
swise@opengridcomputing.com, syzkaller-bugs@googlegroups.com,
willy@infradead.org
Subject: Re: KASAN: use-after-free Read in cma_cancel_listens
Date: Tue, 29 Oct 2019 15:48:55 -0300 [thread overview]
Message-ID: <20191029184855.GH6128@ziepe.ca> (raw)
In-Reply-To: <20191024115700.11852-1-hdanton@sina.com>
On Thu, Oct 24, 2019 at 07:57:00PM +0800, Hillf Danton wrote:
> Detect and avoid repeated cancelation.
>
> +++ b/drivers/infiniband/core/cma.c
> @@ -1747,7 +1747,9 @@ static void cma_cancel_listens(struct rd
> * additional listen requests.
> */
> mutex_lock(&lock);
> - list_del(&id_priv->list);
> + if (list_empty(&id_priv->list))
> + goto unlock;
> + list_del_init(&id_priv->list);
>
> while (!list_empty(&id_priv->listen_list)) {
> dev_id_priv = list_entry(id_priv->listen_list.next,
> @@ -1760,6 +1762,7 @@ static void cma_cancel_listens(struct rd
> rdma_destroy_id(&dev_id_priv->id);
> mutex_lock(&lock);
> }
> +unlock:
> mutex_unlock(&lock);
> }
Hum, it seems like a harmless change, but the real issue here is that
cma_cancel_listens() was called twice at all.
It seems pretty clear that the intent was it would be called on the
state, and the state is transitioned away before it is called. Ie see
how cma_cancel_operation() works with the 'state' argument.
So the only way to trigger this is to race two state transitions,
which means this is the usual syzkaller bug, the 'cma_exch'
synchronization scheme is just totally broken.
Jason
next parent reply other threads:[~2019-10-29 18:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191024115700.11852-1-hdanton@sina.com>
2019-10-29 18:48 ` Jason Gunthorpe [this message]
2019-10-24 5:41 syzbot
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=20191029184855.GH6128@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=bvanassche@acm.org \
--cc=danitg@mellanox.com \
--cc=dledford@redhat.com \
--cc=hdanton@sina.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mhjungk@gmail.com \
--cc=parav@mellanox.com \
--cc=shamir.rabinovitch@oracle.com \
--cc=swise@opengridcomputing.com \
--cc=syzbot+57a3b121df74c4eccbc7@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=willy@infradead.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
all inboxes | Powered by JetHome®