linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write
@ 2016-06-02 10:06 Colin King
  2016-06-02 10:53 ` Michael Hennerich
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2016-06-02 10:06 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, linux-iio
  Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The check on reg is off-by-one, it should be >= rather than >. Fix
this to stop an out-of-bounds write to st->channel_modes[reg].

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/iio/dac/ad5592r-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
index 948f600..69bde59 100644
--- a/drivers/iio/dac/ad5592r-base.c
+++ b/drivers/iio/dac/ad5592r-base.c
@@ -525,7 +525,7 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st)
 
 	device_for_each_child_node(st->dev, child) {
 		ret = fwnode_property_read_u32(child, "reg", &reg);
-		if (ret || reg > ARRAY_SIZE(st->channel_modes))
+		if (ret || reg >= ARRAY_SIZE(st->channel_modes))
 			continue;
 
 		ret = fwnode_property_read_u32(child, "adi,mode", &tmp);
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write
  2016-06-02 10:06 [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write Colin King
@ 2016-06-02 10:53 ` Michael Hennerich
  2016-06-03 12:00   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Hennerich @ 2016-06-02 10:53 UTC (permalink / raw)
  To: Colin King, Lars-Peter Clausen, Jonathan Cameron, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio
  Cc: linux-kernel

On 06/02/2016 12:06 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The check on reg is off-by-one, it should be >= rather than >. Fix
> this to stop an out-of-bounds write to st->channel_modes[reg].
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>   drivers/iio/dac/ad5592r-base.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
> index 948f600..69bde59 100644
> --- a/drivers/iio/dac/ad5592r-base.c
> +++ b/drivers/iio/dac/ad5592r-base.c
> @@ -525,7 +525,7 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st)
>
>   	device_for_each_child_node(st->dev, child) {
>   		ret = fwnode_property_read_u32(child, "reg", &reg);
> -		if (ret || reg > ARRAY_SIZE(st->channel_modes))
> +		if (ret || reg >= ARRAY_SIZE(st->channel_modes))
>   			continue;
>
>   		ret = fwnode_property_read_u32(child, "adi,mode", &tmp);
>


-- 
Greetings,
Michael

--
Analog Devices GmbH      Otl-Aicher Strasse 60-64      80807 München
Sitz der Gesellschaft München, Registergericht München HRB 40368,
Geschäftsführer: Peter Kolberg, Ali Raza Husain, Eileen Wynne

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write
  2016-06-02 10:53 ` Michael Hennerich
@ 2016-06-03 12:00   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-06-03 12:00 UTC (permalink / raw)
  To: michael.hennerich, Colin King, Lars-Peter Clausen,
	Hartmut Knaack, Peter Meerwald-Stadler, linux-iio
  Cc: linux-kernel

On 02/06/16 11:53, Michael Hennerich wrote:
> On 06/02/2016 12:06 PM, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The check on reg is off-by-one, it should be >= rather than >. Fix
>> this to stop an out-of-bounds write to st->channel_modes[reg].
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Already have a fix queued from the 29th of April - will push out
in the next few days.  It just managed to miss going out in the
last cycle by a few days.

Thanks,

Jonathan

> 
>> ---
>>   drivers/iio/dac/ad5592r-base.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
>> index 948f600..69bde59 100644
>> --- a/drivers/iio/dac/ad5592r-base.c
>> +++ b/drivers/iio/dac/ad5592r-base.c
>> @@ -525,7 +525,7 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st)
>>
>>       device_for_each_child_node(st->dev, child) {
>>           ret = fwnode_property_read_u32(child, "reg", &reg);
>> -        if (ret || reg > ARRAY_SIZE(st->channel_modes))
>> +        if (ret || reg >= ARRAY_SIZE(st->channel_modes))
>>               continue;
>>
>>           ret = fwnode_property_read_u32(child, "adi,mode", &tmp);
>>
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-03 12:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-02 10:06 [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write Colin King
2016-06-02 10:53 ` Michael Hennerich
2016-06-03 12:00   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).