From: Hugo Lefeuvre <hle@owl.eu.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org,
Marcus Wolf <linux@wolf-entwicklungen.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: pi433: fix race condition in pi433_open
Date: Tue, 19 Jun 2018 09:42:20 -0400 [thread overview]
Message-ID: <20180619134220.GA2396@hle-laptop.local> (raw)
In-Reply-To: <20180619104248.z5nbbakwhjgscufb@mwanda>
[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]
> > It would be great to get rid of this counter, indeed. But how to do it
> > properly without breaking things ? It seems to be useful to me...
>
> These things are refcounted so you can't unload the module while a file
> is open. When we do an open it does a cdev_get(). When we call the
> delete_module syscall, it checks the refcount in try_stop_module() ->
> try_release_module_ref(). It will still let us force a release but
> at that point you're expecting use after frees.
Then I'd like to understand why this counter was introduced if remove
always gets executed after the last release call returned. This was
probably unclear to the original developer.
This TODO seems to be related to this misunderstanding too:
890 /* TODO? guard against device removal before, or while,
891 * we issue this ioctl. --> device_get()
892 */
Device removal can't happen before or during the ioctl execution.
> > Really ? device->spi is NULL-ed in remove() so that operations on
> > remaining fds can detect remove() was already called and free remaining
> > resources:
> >
> > 1296 /* make sure ops on existing fds can abort cleanly */
> > 1297 device->spi = NULL;
>
> That's when we're unloading the module so there aren't any users left.
I'll submit an updated version of my patch getting rid of the counter
and addressing the remaining race conditions.
Thanks !
Regards,
Hugo
--
Hugo Lefeuvre (hle) | www.owl.eu.com
4096/ 9C4F C8BF A4B0 8FC5 48EB 56B8 1962 765B B9A8 BACA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2018-06-19 13:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 2:24 Hugo Lefeuvre
2018-06-18 10:18 ` Dan Carpenter
2018-06-19 3:11 ` Hugo Lefeuvre
2018-06-19 10:42 ` Dan Carpenter
2018-06-19 13:42 ` Hugo Lefeuvre [this message]
2018-06-19 14:08 ` Dan Carpenter
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=20180619134220.GA2396@hle-laptop.local \
--to=hle@owl.eu.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@wolf-entwicklungen.de \
/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®