From: Hugo Lefeuvre <hle@owl.eu.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
kernelnewbies@kernelnewbies.org
Subject: Re: [PATCH v2] staging: pi433: add mutex fixing concurrency issues.
Date: Thu, 7 Jun 2018 08:45:03 -0400 [thread overview]
Message-ID: <20180607124216.GA2329@hle-laptop.local> (raw)
In-Reply-To: <20180602175649.GA2816@hle-laptop.local>
> Add a mutex fixing a potential NULL pointer dereference in the pi433
> driver.
>
> If pi433_release and pi433_ioctl are concurrently called,
> pi433_release might set filp->private_data to NULL while pi433_ioctl
> is still accessing it, leading to NULL pointer dereference. This issue
> might also affect pi433_write and pi433_read.
>
> The newly introduced mutex makes sure that instance data
> will not be modified simultaneously by pi433_release, pi433_write,
> pi433_read or pi433_ioctl.
>
> The mutex is stored in a newly introduced struct pi433_data, which
> wraps struct pi433_instance and its mutex.
>
> Make filp->private_data point to a struct pi433_data, allowing to
> acquire the lock before accessing the struct pi433_instance.
>
> Signed-off-by: Hugo Lefeuvre <hle@owl.eu.com>
> ---
> Changes in v2:
> - Use mutex instead of rw semaphore.
> - Introduce struct pi433_data in order to allow functions to lock
> before dereferencing instance pointer.
> - Make filp->private_data point to a struct pi433_data.
> - Add missing braces.
After discussing this issue on the kernel newbies mailing list[0] we
came to the conclusion that it is very unlikely that pi433_release and
pi433_ioctl would ever run concurrently in this case. This is also
true for read/write. Unless one can find a situation where this might
happen, I think we should not add this potentially unnecessary lock.
Regards,
Hugo
[0] http://lists.kernelnewbies.org/pipermail/kernelnewbies/2018-June/019131.html
--
Hugo Lefeuvre (hle) | www.owl.eu.com
4096/ 9C4F C8BF A4B0 8FC5 48EB 56B8 1962 765B B9A8 BACA
next prev parent reply other threads:[~2018-06-07 12:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-02 17:56 Hugo Lefeuvre
2018-06-07 12:45 ` Hugo Lefeuvre [this message]
2018-06-09 8:12 ` Valentin Vidic
2018-06-09 15:48 ` Hugo Lefeuvre
2018-06-12 12:11 ` Dan Carpenter
2018-06-13 0:58 ` Hugo Lefeuvre
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=20180607124216.GA2329@hle-laptop.local \
--to=hle@owl.eu.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernelnewbies@kernelnewbies.org \
--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®