All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Shengzhou.Liu-KZfg59tc24xl57MIdRCFDg@public.gmane.org" <Shengzhou.Liu-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
To: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: RE: [PATCH] of: fix of_property_read_string
Date: Wed, 8 Apr 2015 06:29:18 +0000	[thread overview]
Message-ID: <BLUPR03MB391F3BA6A3691F36D73D5EDF8FC0@BLUPR03MB391.namprd03.prod.outlook.com> (raw)
In-Reply-To: <CAL_JsqLpD8UXoHZ-KF74LaN5HEvu3bpu6aeO9_SOHYrut0nV_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

> On Tue, Apr 7, 2015 at 5:11 AM, Shengzhou Liu
> <Shengzhou.Liu@freescale.com> wrote:
> > In of_property_read_string function, strnlen(prop->value,
> > prop->length) is always less or equal to prop->length, and we should
> allow the '=='
> > condition, so let's remove the original unreasonable condition.
> 
> I believe we don't want to allow equal because prop->length should
> include the \0 termination while strnlen will not.
> 
> Rob

Yes, I thought so, ideally prop->length should be assigned with strlen(value)+1, 
but unfortunately in u-boot and kernel there are too many callers that have prop->length assigned 
with strlen(value) instead of strlen(value)+1, in practice, we can allow equal. 

For example, in of_property_read_string_helper function, following two lines had been removed by commit 6faa2909871d8937.
-       if (strnlen(prop->value, prop->length) >= prop->length)
-               return -EILSEQ;

So allowing equal should be acceptable, because in this function, the equal can't prevent stack overflow issue. 


  parent reply	other threads:[~2015-04-08  6:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 10:11 [PATCH] of: fix of_property_read_string Shengzhou Liu
     [not found] ` <1428401462-5907-1-git-send-email-Shengzhou.Liu-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-04-07 15:31   ` Rob Herring
     [not found]     ` <CAL_JsqLpD8UXoHZ-KF74LaN5HEvu3bpu6aeO9_SOHYrut0nV_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-08  6:29       ` Shengzhou.Liu-KZfg59tc24xl57MIdRCFDg [this message]
     [not found]         ` <BLUPR03MB391F3BA6A3691F36D73D5EDF8FC0-GeMU99GfrrvhK2sv/vn9KOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>
2015-04-08 14:25           ` Rob Herring
     [not found]             ` <CAL_JsqL1+oXxV=4pNieCD=+8qb9-9GKREg366Mj8wu3sPRDzBg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-14  9:16               ` Shengzhou.Liu-KZfg59tc24xl57MIdRCFDg

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=BLUPR03MB391F3BA6A3691F36D73D5EDF8FC0@BLUPR03MB391.namprd03.prod.outlook.com \
    --to=shengzhou.liu-kzfg59tc24xl57midrcfdg@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 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.