lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <55F8D3AF.9070503@kernel.org>
Date:	Tue, 15 Sep 2015 21:27:59 -0500
From:	Rob Herring <robh@...nel.org>
To:	Peng Fan <van.freenix@...il.com>
Cc:	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
	Frank Rowand <frowand.list@...il.com>,
	Grant Likely <grant.likely@...aro.org>
Subject: Re: [PATCH] drivers: of: check input parameter name for
 __of_find_property

On 09/15/2015 07:16 PM, Peng Fan wrote:
> Hi Rob,
> 
> On Tue, Sep 15, 2015 at 10:56:28AM -0500, Rob Herring wrote:
>> On 09/11/2015 08:44 AM, Peng Fan wrote:
>>> Check input parameter 'name' for __of_find_property. If name is NULL,
>>> of_prop_cmp->strcasecmp may trigger panic.
>>
>> Arguably that could be a feature. Do you have a usecase where name being
>> NULL is valid and panicking is a problem?
> 
> In drivers/pinctrl/devicetree.c
> 
> 195                 propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state);
> 196                 prop = of_find_property(np, propname, &size);
> 197                 kfree(propname);
> 198                 if (!prop)
> 199                         break;
> 
> If propname is NULL, of_find_property may trigger panic. Anyway propname should be checked
> before passing to of_find_property.

propname will only be NULL if the memory allocation failed which gives
you a big warning message. I don't think you would want to continue on
in this case.

So I'm inclined to leave this as is with passing NULL to
of_find_property to always be an error and fatal.

Rob

> I did not met panic message. I wrote this patch when I was reading the piece code.
> I think the name parameter should be checked before doing string compare.
> 
> Regards,
> Peng.
> 
>>
>> Rob
>>
>>>
>>> Signed-off-by: Peng Fan <van.freenix@...il.com>
>>> Cc: Rob Herring <robh+dt@...nel.org>
>>> Cc: Frank Rowand <frowand.list@...il.com>
>>> Cc: Grant Likely <grant.likely@...aro.org>
>>> ---
>>>  drivers/of/base.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/of/base.c b/drivers/of/base.c
>>> index 8b5a187..e41436d 100644
>>> --- a/drivers/of/base.c
>>> +++ b/drivers/of/base.c
>>> @@ -215,7 +215,7 @@ static struct property *__of_find_property(const struct device_node *np,
>>>  {
>>>  	struct property *pp;
>>>  
>>> -	if (!np)
>>> +	if (!np || !name)
>>>  		return NULL;
>>>  
>>>  	for (pp = np->properties; pp; pp = pp->next) {
>>>
>>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ