HID: hid-lg4ff: Fix uninit-value set_autocenter_default
PATCH 1/1 HID: hid-lg4ff: Fix uninit-value set_autocenter_default
syzbot found a problem using of uinit pointer inlg4ff_set_autocenter_default().
Tested by syzbot:
https://groups.google.com/d/msg/syzkaller-bugs/ApnMLW6sfKE/Qq0bIHGEAQAJ
--- drivers/hid/hid-lg4ff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hid/hid-lg4ff.c +3 -3
@@ -468,10 +468,10 @@ static int lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effecstatic void lg4ff_set_autocenter_default (struct input_dev *dev,u16 magnitude) {struct hid_device *hid =input_get_drvdata (dev); -s32 *value; +s32 *value =NULL ;u32 expand_a, expand_b; -struct lg4ff_device_entry *entry; -struct lg_drv_data *drv_data; +struct lg4ff_device_entry *entry =NULL ; +struct lg_drv_data *drv_data =NULL ;unsigned long flags; drv_data =hid_get_drvdata (hid);
Signature · 1 line
2.20.1
Quoted 9 lines · Phong Tran
syzbot found a problem using of uinit pointer in
lg4ff_set_autocenter_default().Reported-by [email protected]Tested by syzbot:
https://groups.google.com/d/msg/syzkaller-bugs/ApnMLW6sfKE/Qq0bIHGEAQAJ
This seems weird to me:
the syzbot link above is about hid_get_drvdata(hid), and, as I read it, the possibility that hid might not have an initialized value.
Here you are changing the initialized values of value, entry and drv_data, all 3 are never used before their first assignment.
I have a feeling this particular syzbot check has already been fixed upstream by d9d4b1e46d95 "HID: Fix assumption that devices have inputs".
Cheers,
Benjamin
Quoted 25 lines
Signed-off-by Phong Tran <[email protected]>--- drivers/hid/hid-lg4ff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/hid/hid-lg4ff.c +3
-4@@ -468,10 +468,10 @@ static int lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effecstatic void lg4ff_set_autocenter_default (struct input_dev *dev,u16 magnitude) {struct hid_device *hid =input_get_drvdata (dev); -s32 *value; +s32 *value =NULL ;u32 expand_a, expand_b; -struct lg4ff_device_entry *entry; -struct lg_drv_data *drv_data; +struct lg4ff_device_entry *entry =NULL ; +struct lg_drv_data *drv_data =NULL ;unsigned long flags; drv_data =hid_get_drvdata (hid); --
Quoted 2 lines
2.20.1
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 7 lines · Benjamin Tissoires
Quoted 6 lines · Phong Tran
syzbot found a problem using of uinit pointer in
lg4ff_set_autocenter_default().Reported-by [email protected]
Quoted 9 lines
Quoted 3 lines
Tested by syzbot:
https://groups.google.com/d/msg/syzkaller-bugs/ApnMLW6sfKE/Qq0bIHGEAQAJ
This seems weird to me:
the syzbot link above is about
hid_get_drvdata(hid), and, as I read it, the possibility that hid might not have an initialized value.
In the dashboard [1] shows
BUG: KMSAN: uninit-value in dev_get_drvdata include/linux/device.h:1388 [inline] BUG: KMSAN: uninit-value in hid_get_drvdata include/linux/hid.h:628 [inline] BUG: KMSAN: uninit-value in lg4ff_set_autocenter_default+0x23a/0xa20 drivers/hid/hid-lg4ff.c:477
base on that I did the initialization the pointer in the patch.
Quoted 7 lines
Here you are changing the initialized values of value, entry and
drv_data, all 3 are never used before their first assignment.I have a feeling this particular syzbot check has already been fixed upstream by
d9d4b1e46d95"HID: Fix assumption that devices have inputs".
I think the commit d9d4b1 fixed this report [2] by syzbot.
[1] https://syzkaller.appspot.com/bug?extid=1234691fec1b8ceba8b1
[2] https://syzkaller.appspot.com/bug?extid=403741a091bf41d4ae79
regards,
Phong.
Quoted 31 lines
Cheers,
BenjaminQuoted 27 lines
Signed-off-by Phong Tran <[email protected]>--- drivers/hid/hid-lg4ff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/hid/hid-lg4ff.c +3
-4@@ -468,10 +468,10 @@ static int lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effecstatic void lg4ff_set_autocenter_default (struct input_dev *dev,u16 magnitude) {struct hid_device *hid =input_get_drvdata (dev); -s32 *value; +s32 *value =NULL ;u32 expand_a, expand_b; -struct lg4ff_device_entry *entry; -struct lg_drv_data *drv_data; +struct lg4ff_device_entry *entry =NULL ; +struct lg_drv_data *drv_data =NULL ;unsigned long flags; drv_data =hid_get_drvdata (hid); --2.20.1
Quoted 35 lines · Phong Tran
Quoted 7 lines · Benjamin Tissoires
Quoted 6 lines · Phong Tran
syzbot found a problem using of uinit pointer in
lg4ff_set_autocenter_default().Reported-by [email protected]Quoted 9 lines
Quoted 3 lines
Tested by syzbot:
https://groups.google.com/d/msg/syzkaller-bugs/ApnMLW6sfKE/Qq0bIHGEAQAJ
This seems weird to me:
the syzbot link above is about
hid_get_drvdata(hid), and, as I read it, the possibility that hid might not have an initialized value.In the dashboard [1] shows
BUG: KMSAN: uninit-value in dev_get_drvdata include/linux/device.h:1388 [inline] BUG: KMSAN: uninit-value in hid_get_drvdata include/linux/hid.h:628 [inline] BUG: KMSAN: uninit-value in lg4ff_set_autocenter_default+0x23a/0xa20
drivers/hid/hid-lg4ff.c:477
base on that I did the initialization the pointer in the patch.Quoted 7 lines
Here you are changing the initialized values of value, entry and
drv_data, all 3 are never used before their first assignment.I have a feeling this particular syzbot check has already been fixed upstream by
d9d4b1e46d95"HID: Fix assumption that devices have inputs".
Quoted 4 lines
I think the commit d9d4b1 fixed this report [2] by syzbot.
[1] https://syzkaller.appspot.com/bug?extid=1234691fec1b8ceba8b1
[2] https://syzkaller.appspot.com/bug?extid=403741a091bf41d4ae79
As you can see in my long discussion with syzbot today, d9d4b1 also fixed that one.
https://groups.google.com/forum/#!msg/syzkaller-bugs/ApnMLW6sfKE/Qq0bIHGEAQAJ
Cheers,
Benjamin
Quoted 35 lines
regards,
Phong.Quoted 31 lines
Cheers,
BenjaminQuoted 27 lines
Signed-off-by Phong Tran <[email protected]>--- drivers/hid/hid-lg4ff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/hid/hid-lg4ff.c +3
-4@@ -468,10 +468,10 @@ static int lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effecstatic void lg4ff_set_autocenter_default (struct input_dev *dev,u16 magnitude) {struct hid_device *hid =input_get_drvdata (dev); -s32 *value; +s32 *value =NULL ;u32 expand_a, expand_b; -struct lg4ff_device_entry *entry; -struct lg_drv_data *drv_data; +struct lg4ff_device_entry *entry =NULL ; +struct lg_drv_data *drv_data =NULL ;unsigned long flags; drv_data =hid_get_drvdata (hid); --2.20.1