All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alison Schofield <amsfield22@gmail.com>
To: Bhumika Goyal <bhumirks@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Julia Lawall <julia.lawall@lip6.fr>,
	outreachy-kernel@googlegroups.com, knaack.h@gmx.de,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"Hennerich, Michael" <Michael.Hennerich@analog.com>
Subject: Re: [Outreachy kernel] [PATCH] Staging: iio: trigger: Use devm functions
Date: Fri, 14 Oct 2016 12:27:14 -0700	[thread overview]
Message-ID: <20161014192713.GA2356@d830.WORKGROUP> (raw)
In-Reply-To: <b02b84c9-0575-d10d-6b43-d95d167a2429@metafoo.de>

On Mon, Sep 19, 2016 at 10:06:08PM +0200, Lars-Peter Clausen wrote:
> On 09/19/2016 09:29 PM, Jonathan Cameron wrote:
> > On 19/09/16 10:21, Julia Lawall wrote:
> >>
> >>
> >> On Mon, 19 Sep 2016, Bhumika Goyal wrote:
> >>
> >>> On Mon, Sep 19, 2016 at 11:14 AM, Alison Schofield <amsfield22@gmail.com> wrote:
> >>>> On Mon, Sep 19, 2016 at 02:46:50AM +0530, Bhumika Goyal wrote:
> >>>>> Use managed resource functions devm_iio_trigger_alloc and
> >>>>> devm_request_irq instead of iio_trigger_alloc and request_irq.
> >>>>> Remove corresponding calls to free_irq in the probe and remove
> >>>>> functions. Drop the now unnecessary goto labels and replace various
> >>>>> gotos with direct returns.
> >>>>> request_irq replacement done using coccinelle.
> >>>>
> >>>> Hi Bhumika,
> >>>> Thanks for the patch.  This seems like it's worthy of 2 separate
> >>>> patches.
> >>>>
> >>>> Also, I'm a bit confused with why I don't see an iio_trigger_free
> >>>> that is going away, when you switch to the devm_iio_trigger_alloc
> >>>> functions, but I realize there isn't one there to remove. hmm???
> >>>>
> >>>> alisons
> >>>>
> >>>
> >>> Hey Alison,
> >>> Ok, I will separate this in two patches. I will do
> >>> devm_iio_trigger_alloc in patch 1 and devm_request_irq in patch 2 as
> >>> devm_request_irq requires all previous memory allocations to be devms.
> >>> Regarding iio_trigger_free I didn't find any in either of the two
> >>> functions(probe and remove).
> >>> Thanks for the input.
> >>
> >> I think that normally people devmify everything at once.
> > I would as well.  It is 'kind of' one change...
> >>
> >> I dimly recollect that iio_trigger_unregister does the free.  Check
> >> whether this is the case, and whether it is devm safe.
> > Given it's referenced on the next line I certainly hope it doesn't ;)
> > There are quite a few reasons this one is in staging!
> 
> For some reason this driver uses iio_trigger_put() instead of
> iio_trigger_free(). Which is wrong, since iio_trigger_put() does an
> additional module_put() which would release a reference we've never gained.
> So the first fix should be to replace iio_trigger_put() with
> iio_trigger_free() (which is a patch for stable) and then switch to the devm
> version and remove the iio_trigger_free() (which is a patch for next).
> 
> This does not seem to be the only driver that gets this wrong,
> iio-trig-sysfs and iio-trig-interrupt are also affected. These would make a
> good target for further patches.
> 
> Bonus points if you can present a proof-of-concept that exploits this bug to
> run arbitrary code with kernel privileges.
> 
> There seems to be another bug regarding trigger reference counting in
> iio_trigger_write_current(). The reference to the trigger should be acquired
> in iio_trigger_find_by_name() while holding mutex. Otherwise we risk that
> the trigger is already freed before we grab the reference later in
> iio_trigger_write_current(). That's another opportunity for sending a good
> patch and also some opportunity for bonus points.
> 

Hi Bhumika,
I have interest in working this issue.  Let me know if it's ok for
me to run with.  
Thanks!
alisons


  parent reply	other threads:[~2016-10-14 19:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-18 21:16 [PATCH] Staging: iio: trigger: Use devm functions Bhumika Goyal
2016-09-19  5:44 ` [Outreachy kernel] " Alison Schofield
2016-09-19  5:53   ` Bhumika Goyal
2016-09-19  9:21     ` Julia Lawall
     [not found]       ` <fc36bfeb-abae-f8ad-aca0-161cd6743137@kernel.org>
     [not found]         ` <b02b84c9-0575-d10d-6b43-d95d167a2429@metafoo.de>
2016-10-14 19:27           ` Alison Schofield [this message]
2016-10-15  8:12             ` Bhumika Goyal

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=20161014192713.GA2356@d830.WORKGROUP \
    --to=amsfield22@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=bhumirks@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=julia.lawall@lip6.fr \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=pmeerw@pmeerw.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.