From: Jason Gunthorpe <jgg@mellanox.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Leon Romanovsky <leon@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-rdma@vger.kernel.org, Doug Ledford <dledford@redhat.com>
Subject: Re: [PATCH] infiniband: fix a subtle race condition
Date: Thu, 14 Jun 2018 11:24:41 -0600 [thread overview]
Message-ID: <20180614172441.GE24762@mellanox.com> (raw)
In-Reply-To: <CAM_iQpWz9b01ksW_OUHgr1=pf-bNsq_TxoNCQxuDdhUXfvoyOQ@mail.gmail.com>
On Thu, Jun 14, 2018 at 10:03:09AM -0700, Cong Wang wrote:
> On Thu, Jun 14, 2018 at 7:24 AM, Jason Gunthorpe <jgg@mellanox.com> wrote:
> >
> > This was my brief reaction too, this code path almost certainly has a
> > use-after-free, and we should fix the concurrency between the two
> > places in some correct way..
>
> First of all, why use-after-free could trigger an imbalance unlock?
> IOW, why do we have to solve use-after-free to fix this imbalance
> unlock?
The issue syzkaller hit is that accessing ctx->file does not seem
locked in any way and can race with other manipulations of ctx->file.
So.. for this patch to be correct we need to understand how this
statement:
f = ctx->file
Avoids f becoming a dangling pointer - and without locking, my
suspicion is that it doesn't - because missing locking around
ctx->file is probably the actual bug syzkaller found.
If this is not the case, then add a comment explaining how f's
lifetime is OK.
Otherwise, we need some kind of locking and guessing we need to hold a
kref for f?
> Third of all, the use-after-free I can see (race with ->close) exists
> before my patch, this patch doesn't make it better or worse, nor
> I have any intend to fix it.
I'm not sure that race exists, there should be something that flushes
the WQ on the path to close... (though I have another email that
perhaps that is broken, sigh)
Jason
next prev parent reply other threads:[~2018-06-14 17:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 23:49 [PATCH] infiniband: fix a subtle race condition Cong Wang
2018-06-14 5:34 ` Leon Romanovsky
2018-06-14 6:21 ` Cong Wang
2018-06-14 7:01 ` Leon Romanovsky
2018-06-14 14:24 ` Jason Gunthorpe
2018-06-14 17:03 ` Cong Wang
2018-06-14 17:24 ` Jason Gunthorpe [this message]
2018-06-14 23:14 ` Cong Wang
2018-06-15 2:57 ` Jason Gunthorpe
2018-06-15 17:57 ` Cong Wang
2018-06-15 19:08 ` Jason Gunthorpe
2018-06-18 18:40 ` Cong Wang
2018-06-14 16:57 ` Cong Wang
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=20180614172441.GE24762@mellanox.com \
--to=jgg@mellanox.com \
--cc=dledford@redhat.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/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