* [PATCH] Input: leds - fix out of bound access
@ 2018-04-06 18:12 Dmitry Torokhov
2018-04-10 13:50 ` Sasha Levin
2018-04-12 6:20 ` Peter Hutterer
0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2018-04-06 18:12 UTC (permalink / raw)
To: linux-input; +Cc: linux-kernel, Tasos Sahanidis, Samuel Thibault
UI_SET_LEDBIT ioctl() causes the following KASAN splat when used with
led > LED_CHARGING:
[ 1274.663418] BUG: KASAN: slab-out-of-bounds in input_leds_connect+0x611/0x730 [input_leds]
[ 1274.663426] Write of size 8 at addr ffff88003377b2c0 by task ckb-next-daemon/5128
This happens because we were writing to the led structure before making
sure that it exists.
Reported-by: Tasos Sahanidis <tasos@tasossah.com>
Tested-by: Tasos Sahanidis <tasos@tasossah.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/input-leds.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/input/input-leds.c b/drivers/input/input-leds.c
index 766bf26601163..5f04b2d946350 100644
--- a/drivers/input/input-leds.c
+++ b/drivers/input/input-leds.c
@@ -88,6 +88,7 @@ static int input_leds_connect(struct input_handler *handler,
const struct input_device_id *id)
{
struct input_leds *leds;
+ struct input_led *led;
unsigned int num_leds;
unsigned int led_code;
int led_no;
@@ -119,14 +120,13 @@ static int input_leds_connect(struct input_handler *handler,
led_no = 0;
for_each_set_bit(led_code, dev->ledbit, LED_CNT) {
- struct input_led *led = &leds->leds[led_no];
+ if (!input_led_info[led_code].name)
+ continue;
+ led = &leds->leds[led_no];
led->handle = &leds->handle;
led->code = led_code;
- if (!input_led_info[led_code].name)
- continue;
-
led->cdev.name = kasprintf(GFP_KERNEL, "%s::%s",
dev_name(&dev->dev),
input_led_info[led_code].name);
--
2.17.0.484.g0c8726318c-goog
--
Dmitry
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: leds - fix out of bound access
2018-04-06 18:12 [PATCH] Input: leds - fix out of bound access Dmitry Torokhov
@ 2018-04-10 13:50 ` Sasha Levin
2018-04-12 6:20 ` Peter Hutterer
1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2018-04-10 13:50 UTC (permalink / raw)
To: Sasha Levin, Dmitry Torokhov, linux-input
Cc: linux-kernel, Tasos Sahanidis, stable, stable
Hi,
[This is an automated email]
This commit has been processed because it contains a -stable tag.
The stable tag indicates that it's relevant for the following trees: all
The bot has also determined it's probably a bug fixing patch. (score: 97.7389)
The bot has tested the following trees: v4.16.1, v4.15.16, v4.14.33, v4.9.93, v4.4.127.
v4.16.1: Build OK!
v4.15.16: Build OK!
v4.14.33: Build OK!
v4.9.93: Build OK!
v4.4.127: Build OK!
Please let us know if you'd like to have this patch included in a stable tree.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: leds - fix out of bound access
2018-04-06 18:12 [PATCH] Input: leds - fix out of bound access Dmitry Torokhov
2018-04-10 13:50 ` Sasha Levin
@ 2018-04-12 6:20 ` Peter Hutterer
1 sibling, 0 replies; 3+ messages in thread
From: Peter Hutterer @ 2018-04-12 6:20 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, linux-kernel, Tasos Sahanidis, Samuel Thibault
On Fri, Apr 06, 2018 at 11:12:42AM -0700, Dmitry Torokhov wrote:
> UI_SET_LEDBIT ioctl() causes the following KASAN splat when used with
> led > LED_CHARGING:
>
> [ 1274.663418] BUG: KASAN: slab-out-of-bounds in input_leds_connect+0x611/0x730 [input_leds]
> [ 1274.663426] Write of size 8 at addr ffff88003377b2c0 by task ckb-next-daemon/5128
>
> This happens because we were writing to the led structure before making
> sure that it exists.
>
> Reported-by: Tasos Sahanidis <tasos@tasossah.com>
> Tested-by: Tasos Sahanidis <tasos@tasossah.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Cheers,
Peter
> ---
> drivers/input/input-leds.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/input-leds.c b/drivers/input/input-leds.c
> index 766bf26601163..5f04b2d946350 100644
> --- a/drivers/input/input-leds.c
> +++ b/drivers/input/input-leds.c
> @@ -88,6 +88,7 @@ static int input_leds_connect(struct input_handler *handler,
> const struct input_device_id *id)
> {
> struct input_leds *leds;
> + struct input_led *led;
> unsigned int num_leds;
> unsigned int led_code;
> int led_no;
> @@ -119,14 +120,13 @@ static int input_leds_connect(struct input_handler *handler,
>
> led_no = 0;
> for_each_set_bit(led_code, dev->ledbit, LED_CNT) {
> - struct input_led *led = &leds->leds[led_no];
> + if (!input_led_info[led_code].name)
> + continue;
>
> + led = &leds->leds[led_no];
> led->handle = &leds->handle;
> led->code = led_code;
>
> - if (!input_led_info[led_code].name)
> - continue;
> -
> led->cdev.name = kasprintf(GFP_KERNEL, "%s::%s",
> dev_name(&dev->dev),
> input_led_info[led_code].name);
> --
> 2.17.0.484.g0c8726318c-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-12 6:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-06 18:12 [PATCH] Input: leds - fix out of bound access Dmitry Torokhov
2018-04-10 13:50 ` Sasha Levin
2018-04-12 6:20 ` Peter Hutterer
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).