All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
To: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
Cc: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>,
	"grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	"iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org"
	<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 1/2] of: base: Allow more args than MAX_PHANDLE_ARGS if required
Date: Thu, 16 Jul 2015 13:09:00 +0200	[thread overview]
Message-ID: <20150716110900.GA30130@suse.de> (raw)
In-Reply-To: <20150716102325.GC26390-5wv7dgnIgG8@public.gmane.org>

Hi Will,

On Thu, Jul 16, 2015 at 11:23:26AM +0100, Will Deacon wrote:
> On Thu, Jul 16, 2015 at 09:30:43AM +0100, Joerg Roedel wrote:
> > +struct of_phandle_args *of_alloc_phandle_args(int size)
> > +{
> > +	struct of_phandle_args *args;
> > +	int e = max(0, size - MAX_PHANDLE_ARGS);
> > +
> > +	args =  kzalloc(sizeof(struct of_phandle_args) + e * sizeof(uint32_t),
> > +			GFP_KERNEL);
> 
> Should you also update args->args_count to reflect the extended array?

The args_count member just tells us how many of the array elements are
used and not how many there are. So it doesn't need to be updated here.

> That said, extending the fixed-size array member like this feels a bit
> fragile. Does GCC not complain about out-of-bounds accesses if you
> statically address args->args[MAX_PHANDLE_ARGS]? Admittedly, I can't
> think *why* this would be break (things like additional padding will be
> harmless), but I'm not intimate with the C standard.

Yeah, I agree, it is not the best possible solution. But this way I
don't need to update all callers, and thus it works better with our
development model.

But I am open for suggestions on how to solve this problem better. In
fact, my main motivation in sending this was to get the discussion about
an upstreamable solution started :)

Lets see what the device-tree maintainers have to say.

> I guess the more worrying possibility is if somebody adds a new member to
> the end of of_phandle_args.

I should probably add a comment there.



	Joerg

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: jroedel@suse.de (Joerg Roedel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] of: base: Allow more args than MAX_PHANDLE_ARGS if required
Date: Thu, 16 Jul 2015 13:09:00 +0200	[thread overview]
Message-ID: <20150716110900.GA30130@suse.de> (raw)
In-Reply-To: <20150716102325.GC26390@arm.com>

Hi Will,

On Thu, Jul 16, 2015 at 11:23:26AM +0100, Will Deacon wrote:
> On Thu, Jul 16, 2015 at 09:30:43AM +0100, Joerg Roedel wrote:
> > +struct of_phandle_args *of_alloc_phandle_args(int size)
> > +{
> > +	struct of_phandle_args *args;
> > +	int e = max(0, size - MAX_PHANDLE_ARGS);
> > +
> > +	args =  kzalloc(sizeof(struct of_phandle_args) + e * sizeof(uint32_t),
> > +			GFP_KERNEL);
> 
> Should you also update args->args_count to reflect the extended array?

The args_count member just tells us how many of the array elements are
used and not how many there are. So it doesn't need to be updated here.

> That said, extending the fixed-size array member like this feels a bit
> fragile. Does GCC not complain about out-of-bounds accesses if you
> statically address args->args[MAX_PHANDLE_ARGS]? Admittedly, I can't
> think *why* this would be break (things like additional padding will be
> harmless), but I'm not intimate with the C standard.

Yeah, I agree, it is not the best possible solution. But this way I
don't need to update all callers, and thus it works better with our
development model.

But I am open for suggestions on how to solve this problem better. In
fact, my main motivation in sending this was to get the discussion about
an upstreamable solution started :)

Lets see what the device-tree maintainers have to say.

> I guess the more worrying possibility is if somebody adds a new member to
> the end of of_phandle_args.

I should probably add a comment there.



	Joerg

WARNING: multiple messages have this Message-ID (diff)
From: Joerg Roedel <jroedel@suse.de>
To: Will Deacon <will.deacon@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>,
	"grant.likely@linaro.org" <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 1/2] of: base: Allow more args than MAX_PHANDLE_ARGS if required
Date: Thu, 16 Jul 2015 13:09:00 +0200	[thread overview]
Message-ID: <20150716110900.GA30130@suse.de> (raw)
In-Reply-To: <20150716102325.GC26390@arm.com>

Hi Will,

On Thu, Jul 16, 2015 at 11:23:26AM +0100, Will Deacon wrote:
> On Thu, Jul 16, 2015 at 09:30:43AM +0100, Joerg Roedel wrote:
> > +struct of_phandle_args *of_alloc_phandle_args(int size)
> > +{
> > +	struct of_phandle_args *args;
> > +	int e = max(0, size - MAX_PHANDLE_ARGS);
> > +
> > +	args =  kzalloc(sizeof(struct of_phandle_args) + e * sizeof(uint32_t),
> > +			GFP_KERNEL);
> 
> Should you also update args->args_count to reflect the extended array?

The args_count member just tells us how many of the array elements are
used and not how many there are. So it doesn't need to be updated here.

> That said, extending the fixed-size array member like this feels a bit
> fragile. Does GCC not complain about out-of-bounds accesses if you
> statically address args->args[MAX_PHANDLE_ARGS]? Admittedly, I can't
> think *why* this would be break (things like additional padding will be
> harmless), but I'm not intimate with the C standard.

Yeah, I agree, it is not the best possible solution. But this way I
don't need to update all callers, and thus it works better with our
development model.

But I am open for suggestions on how to solve this problem better. In
fact, my main motivation in sending this was to get the discussion about
an upstreamable solution started :)

Lets see what the device-tree maintainers have to say.

> I guess the more worrying possibility is if somebody adds a new member to
> the end of of_phandle_args.

I should probably add a comment there.



	Joerg


  parent reply	other threads:[~2015-07-16 11:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  8:30 [PATCH 0/2 v2] Fix MAX_PHANDLE_ARGS limitations Joerg Roedel
2015-07-16  8:30 ` Joerg Roedel
2015-07-16  8:30 ` Joerg Roedel
     [not found] ` <1437035444-13867-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-07-16  8:30   ` [PATCH 1/2] of: base: Allow more args than MAX_PHANDLE_ARGS if required Joerg Roedel
2015-07-16  8:30     ` Joerg Roedel
2015-07-16  8:30     ` Joerg Roedel
     [not found]     ` <1437035444-13867-2-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-07-16 10:23       ` Will Deacon
2015-07-16 10:23         ` Will Deacon
2015-07-16 10:23         ` Will Deacon
     [not found]         ` <20150716102325.GC26390-5wv7dgnIgG8@public.gmane.org>
2015-07-16 11:09           ` Joerg Roedel [this message]
2015-07-16 11:09             ` Joerg Roedel
2015-07-16 11:09             ` Joerg Roedel
     [not found]             ` <20150716110900.GA30130-l3A5Bk7waGM@public.gmane.org>
2015-07-24 21:27               ` Rob Herring
2015-07-24 21:27                 ` Rob Herring
2015-07-24 21:27                 ` Rob Herring
2015-07-16  8:30   ` [PATCH 2/2] arm/smmu: Make use of of_parse_phandle_with_var_args Joerg Roedel
2015-07-16  8:30     ` Joerg Roedel
2015-07-16  8:30     ` Joerg Roedel
     [not found]     ` <1437035444-13867-3-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-07-16 10:15       ` Will Deacon
2015-07-16 10:15         ` Will Deacon
2015-07-16 10:15         ` Will Deacon
  -- strict thread matches above, loose matches on Subject: below --
2015-07-16  8:22 [PATCH 0/2 v2] Fix MAX_PHANDLE_ARGS limitations Joerg Roedel
2015-07-16  8:22 ` [PATCH 1/2] of: base: Allow more args than MAX_PHANDLE_ARGS if required Joerg Roedel

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=20150716110900.GA30130@suse.de \
    --to=jroedel-l3a5bk7wagm@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=will.deacon-5wv7dgnIgG8@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.