Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1442512 > unrolled thread

[PATCH] iio: stx104: Store channel output state values as int

Started byWilliam Breathitt Gray <vilhelm.gray@gmail.com>
First post2016-07-13 16:50 +0200
Last post2016-07-25 14:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] iio: stx104: Store channel output state values as int William Breathitt Gray <vilhelm.gray@gmail.com> - 2016-07-13 16:50 +0200
    Re: [PATCH] iio: stx104: Store channel output state values as int Jonathan Cameron <jic23@kernel.org> - 2016-07-24 15:10 +0200
      Re: [PATCH] iio: stx104: Store channel output state values as int William Breathitt Gray <vilhelm.gray@gmail.com> - 2016-07-25 14:50 +0200

#1442512 — [PATCH] iio: stx104: Store channel output state values as int

FromWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Date2016-07-13 16:50 +0200
Subject[PATCH] iio: stx104: Store channel output state values as int
Message-ID<rUtE6-4my-25@gated-at.bofh.it>
The val parameter has a data type of int in the read_raw and write_raw
callbacks. The chan_out_states array should have elements of type int in
order to match the data type of the val parameter.

This patch fixes a possible integer overflow condition when the the int
pointer val is dereferenced to store the unsigned int chan_out_states
element in the read_raw callback.

Fixes: 97a445dad37a ("iio: Add IIO support for the DAC on the Apex Embedded Systems STX104")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/iio/dac/stx104.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c
index 792a971..b22b744 100644
--- a/drivers/iio/dac/stx104.c
+++ b/drivers/iio/dac/stx104.c
@@ -47,7 +47,7 @@ MODULE_PARM_DESC(base, "Apex Embedded Systems STX104 base addresses");
  * @base:		base port address of the IIO device
  */
 struct stx104_iio {
-	unsigned chan_out_states[STX104_NUM_CHAN];
+	int chan_out_states[STX104_NUM_CHAN];
 	unsigned base;
 };
 
-- 
2.7.3

[toc] | [next] | [standalone]


#1449132

FromJonathan Cameron <jic23@kernel.org>
Date2016-07-24 15:10 +0200
Message-ID<rYrkl-8jJ-13@gated-at.bofh.it>
In reply to#1442512
On 13/07/16 15:43, William Breathitt Gray wrote:
> The val parameter has a data type of int in the read_raw and write_raw
> callbacks. The chan_out_states array should have elements of type int in
> order to match the data type of the val parameter.
> 
> This patch fixes a possible integer overflow condition when the the int
> pointer val is dereferenced to store the unsigned int chan_out_states
> element in the read_raw callback.
> 
> Fixes: 97a445dad37a ("iio: Add IIO support for the DAC on the Apex Embedded Systems STX104")
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Isn't this only a problem if an out of range value was written
in the first place?  The values it'll take are only 16bits,
so a simple range check around that would fix the root problem.

J
> ---
>  drivers/iio/dac/stx104.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c
> index 792a971..b22b744 100644
> --- a/drivers/iio/dac/stx104.c
> +++ b/drivers/iio/dac/stx104.c
> @@ -47,7 +47,7 @@ MODULE_PARM_DESC(base, "Apex Embedded Systems STX104 base addresses");
>   * @base:		base port address of the IIO device
>   */
>  struct stx104_iio {
> -	unsigned chan_out_states[STX104_NUM_CHAN];
> +	int chan_out_states[STX104_NUM_CHAN];
>  	unsigned base;
>  };
>  
> 

[toc] | [prev] | [next] | [standalone]


#1449454

FromWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Date2016-07-25 14:50 +0200
Message-ID<rYNux-4Cm-13@gated-at.bofh.it>
In reply to#1449132
On Sun, Jul 24, 2016 at 02:06:49PM +0100, Jonathan Cameron wrote:
>On 13/07/16 15:43, William Breathitt Gray wrote:
>> The val parameter has a data type of int in the read_raw and write_raw
>> callbacks. The chan_out_states array should have elements of type int in
>> order to match the data type of the val parameter.
>> 
>> This patch fixes a possible integer overflow condition when the the int
>> pointer val is dereferenced to store the unsigned int chan_out_states
>> element in the read_raw callback.
>> 
>> Fixes: 97a445dad37a ("iio: Add IIO support for the DAC on the Apex Embedded Systems STX104")
>> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
>Isn't this only a problem if an out of range value was written
>in the first place?  The values it'll take are only 16bits,
>so a simple range check around that would fix the root problem.
>
>J

Please disregard this patch.

When I submitted this patch I had assumed the possibility of platforms
with 16-bit int; if all platforms supported by the Linux kernel have at
minimum 32-bit int, then a simple range check should be sufficient.

William Breathitt Gray

>> ---
>>  drivers/iio/dac/stx104.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c
>> index 792a971..b22b744 100644
>> --- a/drivers/iio/dac/stx104.c
>> +++ b/drivers/iio/dac/stx104.c
>> @@ -47,7 +47,7 @@ MODULE_PARM_DESC(base, "Apex Embedded Systems STX104 base addresses");
>>   * @base:		base port address of the IIO device
>>   */
>>  struct stx104_iio {
>> -	unsigned chan_out_states[STX104_NUM_CHAN];
>> +	int chan_out_states[STX104_NUM_CHAN];
>>  	unsigned base;
>>  };
>>  
>> 
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web