linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: Johan Hovold <johan@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jason Cooper <jason@lakedaemon.net>,
	linux-kernel@vger.kernel.org, stable <stable@vger.kernel.org>
Subject: Re: [PATCH] irqchip/gic-v3: fix ppi-partitions lookup
Date: Sun, 12 Nov 2017 14:47:59 +0100	[thread overview]
Message-ID: <20171112134759.GP11226@localhost> (raw)
In-Reply-To: <20171112123208.759b9a9d@why.wild-wind.fr.eu.org>

On Sun, Nov 12, 2017 at 12:32:08PM +0000, Marc Zyngier wrote:
> On Sat, 11 Nov 2017 17:51:25 +0100
> Johan Hovold <johan@kernel.org> wrote:
> 
> Johan,
> 
> > Fix child-node lookup during initialisation, which ended up searching
> > the whole device tree depth-first starting at the parent rather than
> > just matching on its children.
> > 
> > To make things worse, the parent giq node was prematurely freed, while
> 
> s/giq/gic/.
> 
> Care to point out where that node would be prematurely freed? I don't
> see your patch addressing that either...

of_find_node_by_name() is used for tree-wide searches and, as
documented, drops a reference to its first argument, which in this case
is the parent gic node.

> > the ppi-partitions node was leaked.
> > 
> > Fixes: e3825ba1af3a ("irqchip/gic-v3: Add support for partitioned PPIs")
> > Cc: stable <stable@vger.kernel.org>     # 4.7
> 
> Do you have an example of this causing any trouble in the wild? As far
> as I remember, the whole of_node refcounting isn't really enforced, so
> while this is definitely a bug, it wouldn't cause any harm anywhere.

Node refcounting is enabled with CONFIG_OF_DYNAMIC (e.g. when overlay
support is enabled) and getting the refcounting wrong can lead to all
sorts of issues like use-after-free and crashes.

Using the wrong of-helper this way to lookup child nodes have been
reproduced in several drivers, and I'm trying to fix them all up (and
amend the kernel docs) to prevent this pattern from spreading further.

In general you could end up matching and parsing an unrelated node
with whatever implications that may have for a driver too.

> Or am I missing something obvious?

Feel free to drop the stable tag if you deem the implications for this
particular driver to be benign.

I can't test this one myself, but note that the node refcount is
manipulated also after the unbalanced put (e.g. in
gic_of_setup_kvm_info()).

Thanks,
Johan

  reply	other threads:[~2017-11-12 13:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-11 16:51 [PATCH] irqchip/gic-v3: fix ppi-partitions lookup Johan Hovold
2017-11-12 12:32 ` Marc Zyngier
2017-11-12 13:47   ` Johan Hovold [this message]
2017-11-12 14:28     ` Marc Zyngier

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=20171112134759.GP11226@localhost \
    --to=johan@kernel.org \
    --cc=jason@lakedaemon.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.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;
as well as URLs for NNTP newsgroup(s).