media: v4l2-flash: fix NULL dereference in v4l2_flash_s_ctrl()
PATCH 1/1 media: v4l2-flash: fix NULL dereference in v4l2_flash_s_ctrl()
The NULL check added for fled_cdev before dereference.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/media/v4l2-core/v4l2-flash-led-class.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/v4l2-core/v4l2-flash-led-class.c +4 -0
@@ -291,12 +291,16 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c)* No conversion is needed as LED Flash class also uses * microseconds for flash timeout units. */ +if (!fled_cdev) +return -EINVAL ;return led_set_flash_timeout (fled_cdev, c->val);case V4L2_CID_FLASH_INTENSITY :/* * No conversion is needed as LED Flash class also uses * microamperes for flash intensity units. */ +if (!fled_cdev) +return -EINVAL ;return led_set_flash_brightness (fled_cdev, c->val); }
Signature · 1 line
2.25.1
PATCH 2/2 misc: genwqe: card_dev: Array index overflow fix in ddcb_cmd_fixups()
&cmd->asiv of size 96 can overflow because its index (asiv_offs + 8) can be equal to 96 (0x58 + 0x08) that is out of range.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/misc/genwqe/card_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/genwqe/card_dev.c +1 -1
@@ -867,7 +867,7 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req)struct genwqe_ddcb_cmd *cmd = &req->cmd;struct dma_mapping *m; -for (i =0 , asiv_offs =0x00 ; asiv_offs <=0x58 ; +for (i =0 , asiv_offs =0x00 ; asiv_offs <0x58 ; i++, asiv_offs +=0x08 ) {u64 u_addr;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerRe: [PATCH 2/2] misc: genwqe: card_dev: Array index overflow fix in ddcb_cmd_fixups()
Quoted 27 lines · Aleksandr Burakov
&cmd->asivof size 96 can overflow because its index (asiv_offs+ 8) can be equal to 96 (0x58+0x08) that is out of range.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by Aleksandr Burakov <[email protected]>Fixes eaf4722d4645 ("GenWQE Character device and DDCB queue")--- drivers/misc/genwqe/card_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/misc/genwqe/card_dev.c +1
-1@@ -867,7 +867,7 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req)struct genwqe_ddcb_cmd *cmd = &req->cmd;struct dma_mapping *m; -for (i =0 , asiv_offs =0x00 ; asiv_offs <=0x58 ; +for (i =0 , asiv_offs =0x00 ; asiv_offs <0x58 ; i++, asiv_offs +=0x08 ) {u64 u_addr;Signature · 1 line
2.25.1
Where is patch 1/2 of this series?
Re: [PATCH 2/2] misc: genwqe: card_dev: Array index overflow fix in ddcb_cmd_fixups()
Hello!
The subject was created this way due to technical issues. There is only one patch here.
With best regards,
A. Burakov
----- Исходное сообщение -----
От: "Greg Kroah-Hartman" <[email protected]>
Кому: "Александр Бураков" <[email protected]>
Копия: "Frank Haverkamp" <[email protected]>, "Arnd Bergmann" <[email protected]>, [email protected], [email protected] Отправленные: Среда, 7 Декабрь 2022 г 19:23:12
Тема: Re: [PATCH 2/2] misc: genwqe: card_dev: Array index overflow fix in ddcb_cmd_fixups()
Quoted 27 lines · Aleksandr Burakov
&cmd->asivof size 96 can overflow because its index (asiv_offs+ 8) can be equal to 96 (0x58+0x08) that is out of range.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by Aleksandr Burakov <[email protected]>Fixes eaf4722d4645 ("GenWQE Character device and DDCB queue")--- drivers/misc/genwqe/card_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/misc/genwqe/card_dev.c +1
-1@@ -867,7 +867,7 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req)struct genwqe_ddcb_cmd *cmd = &req->cmd;struct dma_mapping *m; -for (i =0 , asiv_offs =0x00 ; asiv_offs <=0x58 ; +for (i =0 , asiv_offs =0x00 ; asiv_offs <0x58 ; i++, asiv_offs +=0x08 ) {u64 u_addr;Signature · 1 line
2.25.1
Where is patch 1/2 of this series?
Greg Kroah-Hartman
maintainerRe: [PATCH 2/2] misc: genwqe: card_dev: Array index overflow fix in ddcb_cmd_fixups()
A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
A: No.
Q: Should I include quotations after my reply?
http://daringfireball.net/2007/07/on_top
Quoted 3 lines · Александр Бураков
Hello!
The subject was created this way due to technical issues. There is only one patch here.
Great, then please fix up those issues and resend a version 2 of this patch, otherwise it confuses us all. Please remember that we optimize for review, and as such, if you make a mistake like this, it's up to you to fix it up, not us.
thanks,
greg k-h
Hi Alexandr,
Quoted 21 lines · Aleksandr Burakov
The NULL check added for
fled_cdevbefore dereference.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by Aleksandr Burakov <[email protected]>Fixes 42bd6f59ae90 ("media: Add registration helpers for V4L2 flash sub-devices")--- drivers/media/v4l2-core/v4l2-flash-led-class.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/media/v4l2-core/v4l2-flash-led-class.c +2
-0@@ -291,12 +291,16 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c)* No conversion is needed as LED Flash class also uses * microseconds for flash timeout units. */ +if (!fled_cdev) +return -EINVAL ;return led_set_flash_timeout (fled_cdev, c->val);
drivers/media/v4l2-core/v4l2-flash-led-class.c static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c) · line 306
Quoted 10 lines
drivers/media/v4l2-core/v4l2-flash-led-class.c +2
-0case V4L2_CID_FLASH_INTENSITY :/* * No conversion is needed as LED Flash class also uses * microamperes for flash intensity units. */ +if (!fled_cdev) +return -EINVAL ;return led_set_flash_brightness (fled_cdev, c->val); }
fled_cdev won't be NULL above, this is checked elsewhere in the V4L2 flash LED class code. I guess the question then is whether doing such a check is meaningful. It would require a bug elsewhere in the code to happen.
Signature · 3 lines
Kind regards, Sakari Ailus