From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Jia-Ju Bai <baijiaju1990@gmail.com>,
dhowells@redhat.com, joel@jms.id.au, eajames@linux.vnet.ibm.com,
andrew@aj.id.au
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fsi:fsi-sbefifo: Fix possible concurrency use-after-free bugs in sbefifo_user_release
Date: Fri, 04 Jan 2019 14:26:03 +1100 [thread overview]
Message-ID: <7bbf788adeac78da48a83b100f820b962b16ba19.camel@kernel.crashing.org> (raw)
In-Reply-To: <798fbb98-0cba-07f8-2165-180c63012e95@gmail.com>
On Fri, 2019-01-04 at 10:26 +0800, Jia-Ju Bai wrote:
>
> On 2019/1/4 8:47, Benjamin Herrenschmidt wrote:
> > On Wed, 2018-12-26 at 21:56 +0800, Jia-Ju Bai wrote:
> > > In drivers/fsi/fsi-sbefifo.c, the functions sbefifo_user_release(),
> > > sbefifo_user_read() and sbefifo_user_write() may be concurrently executed.
> > So after refreshing my mind, looking at the code and talking with Al, I
> > really dont' see what race you are trying to fix here.
> >
> > read/write should never be concurrent with release for a given file and
> > the stuff we are protecting here is local to the file instance.
> >
> > Do you have an actual problem you observed ?
> >
>
> Thanks for the reply.
>
> In fact, this report is found by a static tool written by myself,
> instead of real execution.
> My tool found that in some drivers, for the structure "struct
> file_operations", the code in intetrfaces ".read" , "write" and
> ".release" are protected by the same lock.
> The functions kcs_bmc_read(), kcs_bmc_write() and kcs_bmc_release() are
> examples.
> Thus, my tool inferred that the intetrfaces ".read" , "write" and
> ".release" of "struct file_operations" can be concurrently executed, and
> generated this report.
> I manually checked this report, but I was not very sure of it, so I
> marked it as a "possible bug" and reported it.
So what happens is that they cannot be executed concurrently for a
given struct file. But they can be for separate files.
In the fsi-sbefifo case, all of the data and the lock are part of a
private structure which is allocated in open() and thus is per-file
instance, so there should be no race.
In the example you gave, kcs_bmc.c, the data and lock are part of a
per-device (struct kcs_bmc) and thus shared by all file instances. So
in that case, the race does exist.
> From your message, now I know my report is false, and ".read" , "write"
> cannot be concurrently executed with ".release" for a given file.
> Sorry for my false report, and thanks for your message.
Right, your tool is valuable as pre-screening but you need in addition
to check (probably manually) whether the data accessed (and lock) are
shared by multiple open file instances or are entirely local to a given
file instance.
Cheers,
Ben.
prev parent reply other threads:[~2019-01-04 3:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 13:56 Jia-Ju Bai
2019-01-02 9:34 ` David Howells
2019-01-03 3:27 ` Benjamin Herrenschmidt
2019-01-03 4:26 ` Benjamin Herrenschmidt
2019-01-04 0:47 ` Benjamin Herrenschmidt
2019-01-04 2:26 ` Jia-Ju Bai
2019-01-04 3:26 ` Benjamin Herrenschmidt [this message]
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=7bbf788adeac78da48a83b100f820b962b16ba19.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=andrew@aj.id.au \
--cc=baijiaju1990@gmail.com \
--cc=dhowells@redhat.com \
--cc=eajames@linux.vnet.ibm.com \
--cc=joel@jms.id.au \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®