2017-03-25 16:02:21

by Giedrius Statkevičius

[permalink] [raw]
Subject: [PATCH] power: supply: lp8788: prevent out of bounds array access

val might become 7 in which case stime[7] (array of length 7) would be
accessed during the scnprintf call later and that will cause issues.
Obviously, string concatenation is not intended here so just a comma needs
to be added to fix the issue.

Signed-off-by: Giedrius Statkevičius <[email protected]>
---
drivers/power/supply/lp8788-charger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
index 509e2b341bd6..677f7c40b25a 100644
--- a/drivers/power/supply/lp8788-charger.c
+++ b/drivers/power/supply/lp8788-charger.c
@@ -651,7 +651,7 @@ static ssize_t lp8788_show_eoc_time(struct device *dev,
{
struct lp8788_charger *pchg = dev_get_drvdata(dev);
char *stime[] = { "400ms", "5min", "10min", "15min",
- "20min", "25min", "30min" "No timeout" };
+ "20min", "25min", "30min", "No timeout" };
u8 val;

lp8788_read_byte(pchg->lp, LP8788_CHG_EOC, &val);
--
2.12.0


2017-03-27 23:24:31

by Kim, Milo

[permalink] [raw]
Subject: Re: [PATCH] power: supply: lp8788: prevent out of bounds array access

On 3/26/2017 1:00 AM, Giedrius Statkevičius wrote:
> val might become 7 in which case stime[7] (array of length 7) would be
> accessed during the scnprintf call later and that will cause issues.
> Obviously, string concatenation is not intended here so just a comma needs
> to be added to fix the issue.
>
> Signed-off-by: Giedrius Statkevičius <[email protected]>

Acked-by: Milo Kim <[email protected]>

> ---
> drivers/power/supply/lp8788-charger.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
> index 509e2b341bd6..677f7c40b25a 100644
> --- a/drivers/power/supply/lp8788-charger.c
> +++ b/drivers/power/supply/lp8788-charger.c
> @@ -651,7 +651,7 @@ static ssize_t lp8788_show_eoc_time(struct device *dev,
> {
> struct lp8788_charger *pchg = dev_get_drvdata(dev);
> char *stime[] = { "400ms", "5min", "10min", "15min",
> - "20min", "25min", "30min" "No timeout" };
> + "20min", "25min", "30min", "No timeout" };
> u8 val;
>
> lp8788_read_byte(pchg->lp, LP8788_CHG_EOC, &val);
>

2017-04-08 10:55:35

by Giedrius Statkevičius

[permalink] [raw]
Subject: Re: [PATCH] power: supply: lp8788: prevent out of bounds array access

Ping.

On Tue, Mar 28, 2017 at 2:23 AM, Kim, Milo <[email protected]> wrote:
> On 3/26/2017 1:00 AM, Giedrius Statkevičius wrote:
>>
>> val might become 7 in which case stime[7] (array of length 7) would be
>> accessed during the scnprintf call later and that will cause issues.
>> Obviously, string concatenation is not intended here so just a comma needs
>> to be added to fix the issue.
>>
>> Signed-off-by: Giedrius Statkevičius <[email protected]>
>
>
> Acked-by: Milo Kim <[email protected]>
>
>
>> ---
>> drivers/power/supply/lp8788-charger.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/power/supply/lp8788-charger.c
>> b/drivers/power/supply/lp8788-charger.c
>> index 509e2b341bd6..677f7c40b25a 100644
>> --- a/drivers/power/supply/lp8788-charger.c
>> +++ b/drivers/power/supply/lp8788-charger.c
>> @@ -651,7 +651,7 @@ static ssize_t lp8788_show_eoc_time(struct device
>> *dev,
>> {
>> struct lp8788_charger *pchg = dev_get_drvdata(dev);
>> char *stime[] = { "400ms", "5min", "10min", "15min",
>> - "20min", "25min", "30min" "No timeout" };
>> + "20min", "25min", "30min", "No timeout" };
>> u8 val;
>>
>> lp8788_read_byte(pchg->lp, LP8788_CHG_EOC, &val);
>>
>

2017-04-11 14:19:06

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH] power: supply: lp8788: prevent out of bounds array access

Hi,

On Sat, Mar 25, 2017 at 06:00:49PM +0200, Giedrius Statkevičius wrote:
> val might become 7 in which case stime[7] (array of length 7) would be
> accessed during the scnprintf call later and that will cause issues.
> Obviously, string concatenation is not intended here so just a comma needs
> to be added to fix the issue.
>
> Signed-off-by: Giedrius Statkevičius <[email protected]>
> ---
> drivers/power/supply/lp8788-charger.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
> index 509e2b341bd6..677f7c40b25a 100644
> --- a/drivers/power/supply/lp8788-charger.c
> +++ b/drivers/power/supply/lp8788-charger.c
> @@ -651,7 +651,7 @@ static ssize_t lp8788_show_eoc_time(struct device *dev,
> {
> struct lp8788_charger *pchg = dev_get_drvdata(dev);
> char *stime[] = { "400ms", "5min", "10min", "15min",
> - "20min", "25min", "30min" "No timeout" };
> + "20min", "25min", "30min", "No timeout" };
> u8 val;
>
> lp8788_read_byte(pchg->lp, LP8788_CHG_EOC, &val);

Thanks, queued with Fixes Tag.

-- Sebastian


Attachments:
(No filename) (1.12 kB)
signature.asc (833.00 B)
Download all attachments