devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "Pierre-Clément Tosi" <ptosi@google.com>
Cc: devicetree-compiler@vger.kernel.org,
	Mike McTernan <mikemcternan@google.com>,
	Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH v2] libfdt: fdt_get_alias_namelen: Validate aliases
Date: Wed, 11 Oct 2023 11:33:06 +1100	[thread overview]
Message-ID: <ZSXtQhlDN29ziHF9@zatzit> (raw)
In-Reply-To: <20231010092643.z6okcdpvoj35gs2t@google.com>

[-- Attachment #1: Type: text/plain, Size: 1573 bytes --]

On Tue, Oct 10, 2023 at 10:26:43AM +0100, Pierre-Clément Tosi wrote:
> On Tue, Oct 10, 2023 at 03:56:19PM +1100, David Gibson wrote:
> > On Mon, Oct 09, 2023 at 03:20:04PM +0100, Pierre-Clément Tosi wrote:
> > > Ensure that the alias found matches the device tree specification v0.4:
> > > 
> > >     Each property of the /aliases node defines an alias. The property
> > >     name specifies the alias name. The property value specifies the full
> > >     path to a node in the devicetree.
> > > 
> > > This protects against a stack overflow caused by
> > > 
> > >     fdt_path_offset_namelen(fdt, path, namelen)
> > > 
> > > calling (if 'path' contains no '/')
> > 
> > Uh.. this still seems confusing, or at least misleadingly specific.
> > Having a self-referential alias doesn't really have anything to do
> > with whether the path has any '/' or not.
> 
> Because, even if fdt_path_offset() is called with a path containing one or more
> '/', the recursion will result in a fdt_path_offset() call with a path that
> doesn't have one, right?

Well, not necessarily, but you can get a loop even without that.  Most
trivially with:
	aliases {
		loop = "loop/some/path/or/other"
	};

As long as the first call to fdt_path_offset() has a '/' in it, so
will every subsequent one, but you'll still get infinite recursion
trying to resolve 'loop'.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2023-10-11  0:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 14:20 [PATCH v2] libfdt: fdt_get_alias_namelen: Validate aliases Pierre-Clément Tosi
2023-10-10  4:56 ` David Gibson
2023-10-10  9:26   ` Pierre-Clément Tosi
2023-10-11  0:33     ` David Gibson [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=ZSXtQhlDN29ziHF9@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=devicetree-compiler@vger.kernel.org \
    --cc=mikemcternan@google.com \
    --cc=ptosi@google.com \
    --cc=sjg@chromium.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;
as well as URLs for NNTP newsgroup(s).