leds: mlxreg: Fix possible buffer overflow
Subsystems (2)
PATCH RESEND 1/1 leds: mlxreg: Fix possible buffer overflow
Error was detected by PVS-Studio:
V512 A call of the 'sprintf' function will lead to overflow of the buffer 'led_data->led_cdev_name'.
--- drivers/leds/leds-mlxreg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-mlxreg.c +2 -2
@@ -228,8 +228,8 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv) brightness =LED_OFF ; led_data->base_color =MLXREG_LED_GREEN_SOLID ; } -sprintf (led_data->led_cdev_name,"%s:%s" ,"mlxreg" , - data->label); +snprintf (led_data->led_cdev_name,sizeof (led_data->led_cdev_name), +"mlxreg:%s" , data->label); led_cdev->name = led_data->led_cdev_name; led_cdev->brightness = brightness; led_cdev->max_brightness =LED_ON ;
Signature · 1 line
2.21.0
Pavel Machek
AppliedQuoted 7 lines · Oleh Kravchenko
Error was detected by PVS-Studio:
V512 A call of the 'sprintf' function will lead to overflow of the buffer 'led_data->led_cdev_name'.Acked-by Jacek Anaszewski <[email protected]>Acked-by Pavel Machek <[email protected]>Signed-off-by Oleh Kravchenko <[email protected]>
Thanks for resend, and sorry for the delay.
Note that this would only be security issue if someone did malicious device tree... so... not a security issue :-).
Applied.
Pavel
Quoted 16 lines
index
cabe379071a7..82aea1cd0c12100644drivers/leds/leds-mlxreg.c +2
-2@@ -228,8 +228,8 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv) brightness =LED_OFF ; led_data->base_color =MLXREG_LED_GREEN_SOLID ; } -sprintf (led_data->led_cdev_name,"%s:%s" ,"mlxreg" , - data->label); +snprintf (led_data->led_cdev_name,sizeof (led_data->led_cdev_name), +"mlxreg:%s" , data->label); led_cdev->name = led_data->led_cdev_name; led_cdev->brightness = brightness; led_cdev->max_brightness =LED_ON ;Signature · 1 line
2.21.0
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hello Pavel,
Quoted 5 lines · Pavel Machek
Quoted 4 lines · Oleh Kravchenko
Error was detected by PVS-Studio:
V512 A call of the 'sprintf' function will lead to overflow of the buffer 'led_data->led_cdev_name'.
Quoted 7 lines
Quoted 3 lines
Acked-by Jacek Anaszewski <[email protected]>Acked-by Pavel Machek <[email protected]>Signed-off-by Oleh Kravchenko <[email protected]>Thanks for resend, and sorry for the delay.
Note that this would only be security issue if someone did malicious device tree... so... not a security issue :-).
Agree, very limited case.
But I just want make our kernel more robust and reliable :-)
Quoted 2 lines
Applied.
Thanks!
Quoted 1 line
Pavel