Devicetree
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Zijun Hu <zijun.hu@oss.qualcomm.com>
Cc: Alban Bedel <alban.bedel@lht.dlh.de>,
	driver-core@lists.linux.dev, devicetree@vger.kernel.org,
	Daniel Scally <djrscally@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>, Rob Herring <robh@kernel.org>,
	Saravana Kannan <saravanak@kernel.org>,
	linux-kernel@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH v2 2/2] software node: Fix software_node_get_reference_args() with index -1
Date: Mon, 29 Jun 2026 10:30:36 +0300	[thread overview]
Message-ID: <akIfHJd2gpLC1u5o@ashevche-desk.local> (raw)
In-Reply-To: <85b2bac4-9882-4f35-81e4-1718a52aacc9@oss.qualcomm.com>

On Sat, Jun 27, 2026 at 07:50:12AM +0800, Zijun Hu wrote:
> On 6/18/2026 11:20 PM, Alban Bedel wrote:
> > The bounds check for the index passed to
> > software_node_get_reference_args() was failing when passed UINT_MAX,
> > this in turn would lead to an out of bound access in the property
> > array. Fix the bound check to also cover the UINT_MAX case.
> > 
> > Fixes: 31e4e12e0e960 ("software node: Correct a OOB check in software_node_get_reference_args()")
> 
> i think the fix tag may not be right.
> 
> for original express before the fix tag: if (index * sizeof(*ref) > prop->length)
> 
> for UINT_MAX, multiplication overflow?

I agree that Fixes tag may be not the best chosen.

...

> > software_node_get_reference_args(const struct fwnode_handle *fwnode,

> >  	if (prop->is_inline)
> >  		return -EINVAL;
> >  
> > -	if ((index + 1) * sizeof(*ref) > prop->length)
> > +	if (index >= prop->length / sizeof(*ref))
> >  		return -ENOENT;
> >  
> 
> who will use UINT_MAX ?
> 
> This function is a interface function.  the best fix should check
> input parameter @index and return -EINVAL if it is not expected?

And how do you know which index is allowed without doing that division?
Basically this patch does what you asked for: check input parameter for
the allowed range (which is dynamic, depending on the property length and
size of the reference structure.


-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-06-29  7:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 15:20 [PATCH v2 1/2] of: property: Fix of_fwnode_get_reference_args() with negative index Alban Bedel
2026-06-18 15:20 ` [PATCH v2 2/2] software node: Fix software_node_get_reference_args() with index -1 Alban Bedel
2026-06-18 15:31   ` sashiko-bot
2026-06-18 18:35   ` Andy Shevchenko
2026-06-22  8:41     ` Alban Bedel
2026-06-26 23:50   ` Zijun Hu
2026-06-29  7:30     ` Andy Shevchenko [this message]
2026-06-29 12:33       ` Zijun Hu
2026-06-29 13:13         ` Andy Shevchenko
2026-06-29 10:50     ` Alban Bedel
2026-06-18 17:09 ` [PATCH v2 1/2] of: property: Fix of_fwnode_get_reference_args() with negative index Rob Herring (Arm)

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=akIfHJd2gpLC1u5o@ashevche-desk.local \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=alban.bedel@lht.dlh.de \
    --cc=dakr@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=djrscally@gmail.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=saravanak@kernel.org \
    --cc=sashiko-bot@kernel.org \
    --cc=zijun.hu@oss.qualcomm.com \
    /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