linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: ad5755: fix off-by-one on devnr limit check
@ 2016-07-25 22:40 Colin King
  2016-08-21 19:30 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2016-07-25 22:40 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 comparison for devnr limits is off-by-one, the current check
allows 0 to AD5755_NUM_CHANNELS and the limit should be in fact
0 to AD5755_NUM_CHANNELS - 1.  This can lead to an out of bounds
write to pdata->dac[devnr]. Fix this by replacing > with >= on the
comparison.

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

diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
index 0fde593..5f79682 100644
--- a/drivers/iio/dac/ad5755.c
+++ b/drivers/iio/dac/ad5755.c
@@ -655,7 +655,7 @@ static struct ad5755_platform_data *ad5755_parse_dt(struct device *dev)
 
 	devnr = 0;
 	for_each_child_of_node(np, pp) {
-		if (devnr > AD5755_NUM_CHANNELS) {
+		if (devnr >= AD5755_NUM_CHANNELS) {
 			dev_err(dev,
 				"There is to many channels defined in DT\n");
 			goto error_out;
-- 
2.8.1

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

* Re: [PATCH] iio: ad5755: fix off-by-one on devnr limit check
  2016-07-25 22:40 [PATCH] iio: ad5755: fix off-by-one on devnr limit check Colin King
@ 2016-08-21 19:30 ` Jonathan Cameron
  2016-08-21 20:07   ` Lars-Peter Clausen
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2016-08-21 19:30 UTC (permalink / raw)
  To: Colin King, Lars-Peter Clausen, Michael Hennerich,
	Hartmut Knaack, Peter Meerwald-Stadler, linux-iio
  Cc: linux-kernel

On 25/07/16 23:40, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The comparison for devnr limits is off-by-one, the current check
> allows 0 to AD5755_NUM_CHANNELS and the limit should be in fact
> 0 to AD5755_NUM_CHANNELS - 1.  This can lead to an out of bounds
> write to pdata->dac[devnr]. Fix this by replacing > with >= on the
> comparison.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Lars? 

Looks correct to me.

I'd also like a fixes tag for this if possible.  Guessing it
might well be the original driver introduction but best to be
sure ;)

Jonathan
> ---
>  drivers/iio/dac/ad5755.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
> index 0fde593..5f79682 100644
> --- a/drivers/iio/dac/ad5755.c
> +++ b/drivers/iio/dac/ad5755.c
> @@ -655,7 +655,7 @@ static struct ad5755_platform_data *ad5755_parse_dt(struct device *dev)
>  
>  	devnr = 0;
>  	for_each_child_of_node(np, pp) {
> -		if (devnr > AD5755_NUM_CHANNELS) {
> +		if (devnr >= AD5755_NUM_CHANNELS) {
>  			dev_err(dev,
>  				"There is to many channels defined in DT\n");
>  			goto error_out;
> 

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

* Re: [PATCH] iio: ad5755: fix off-by-one on devnr limit check
  2016-08-21 19:30 ` Jonathan Cameron
@ 2016-08-21 20:07   ` Lars-Peter Clausen
  2016-08-29 15:16     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2016-08-21 20:07 UTC (permalink / raw)
  To: Jonathan Cameron, Colin King, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio
  Cc: linux-kernel

On 08/21/2016 09:30 PM, Jonathan Cameron wrote:
> On 25/07/16 23:40, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The comparison for devnr limits is off-by-one, the current check
>> allows 0 to AD5755_NUM_CHANNELS and the limit should be in fact
>> 0 to AD5755_NUM_CHANNELS - 1.  This can lead to an out of bounds
>> write to pdata->dac[devnr]. Fix this by replacing > with >= on the
>> comparison.
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> Lars? 
> 
> Looks correct to me.
> 
> I'd also like a fixes tag for this if possible.  Guessing it
> might well be the original driver introduction but best to be
> sure ;)

It's new in 4.8-rc1. It was introduced by the devictree support patch.

Fixes: c947459979c6 ("iio: ad5755: add support for dt bindings")

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

* Re: [PATCH] iio: ad5755: fix off-by-one on devnr limit check
  2016-08-21 20:07   ` Lars-Peter Clausen
@ 2016-08-29 15:16     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2016-08-29 15:16 UTC (permalink / raw)
  To: Lars-Peter Clausen, Colin King, Michael Hennerich,
	Hartmut Knaack, Peter Meerwald-Stadler, linux-iio
  Cc: linux-kernel

On 21/08/16 21:07, Lars-Peter Clausen wrote:
> On 08/21/2016 09:30 PM, Jonathan Cameron wrote:
>> On 25/07/16 23:40, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> The comparison for devnr limits is off-by-one, the current check
>>> allows 0 to AD5755_NUM_CHANNELS and the limit should be in fact
>>> 0 to AD5755_NUM_CHANNELS - 1.  This can lead to an out of bounds
>>> write to pdata->dac[devnr]. Fix this by replacing > with >= on the
>>> comparison.
>>>
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> Lars? 
>>
>> Looks correct to me.
>>
>> I'd also like a fixes tag for this if possible.  Guessing it
>> might well be the original driver introduction but best to be
>> sure ;)
> 
> It's new in 4.8-rc1. It was introduced by the devictree support patch.
> 
> Fixes: c947459979c6 ("iio: ad5755: add support for dt bindings")
Thanks Lars,

Applied to the togreg branch of iio.git - initially pushed out as
testing for the autobuilders to play with it.

Thanks,

Jonathan
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

end of thread, other threads:[~2016-08-29 15:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-25 22:40 [PATCH] iio: ad5755: fix off-by-one on devnr limit check Colin King
2016-08-21 19:30 ` Jonathan Cameron
2016-08-21 20:07   ` Lars-Peter Clausen
2016-08-29 15:16     ` 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).