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]
Date:   Thu, 17 May 2018 09:58:28 -0700
From:   Frank Rowand <frowand.list@...il.com>
To:     Rob Herring <robh+dt@...nel.org>, pantelis.antoniou@...sulko.com,
        Pantelis Antoniou <panto@...oniou-consulting.com>
Cc:     Dan Carpenter <dan.carpenter@...cle.com>,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] of: overlay: validate offset from property fixups

On 05/17/18 09:56, Frank Rowand wrote:
> Hi Rob,
> 
> On 05/16/18 21:19, frowand.list@...il.com wrote:
>> From: Frank Rowand <frank.rowand@...y.com>
>>
>> The smatch static checker marks the data in offset as untrusted,
>> leading it to warn:
>>
>>   drivers/of/resolver.c:125 update_usages_of_a_phandle_reference()
>>   error: buffer underflow 'prop->value' 's32min-s32max'
>>
>> Add check to verify that offset is within the property data.
>>
>> Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
>> Signed-off-by: Frank Rowand <frank.rowand@...y.com>
>> ---
>>  drivers/of/resolver.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
>> index 65d0b7adfcd4..7edfac6f1914 100644
>> --- a/drivers/of/resolver.c
>> +++ b/drivers/of/resolver.c
>> @@ -122,6 +122,11 @@ static int update_usages_of_a_phandle_reference(struct device_node *overlay,
>>  			goto err_fail;
>>  		}
>>  
>> +		if (offset < 0 || offset + sizeof(__be32) > prop->length) {
>> +			err = -EINVAL;
>> +			goto err_fail;
>> +		}
>> +
>>  		*(__be32 *)(prop->value + offset) = cpu_to_be32(phandle);
>>  	}
>>  
>>
> 
> I should have mentioned that this results in a new compile warning
> for W=2 and W=3.  The new if statement results in:
> 

W=2 warning is:

> drivers/of/resolver.c:125:45: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

W=3 warning is:

drivers/of/resolver.c:125:3: warning: conversion to 'unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]

> 
> There are other pre-existing warnings in the same file for comparing
> an integer to prop->length.  The correct solution is probably to
> change the type of the length field in struct property to be
> unsigned.  I have added that task to my todo list.
> 
> -Frank
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ