isdn/gigaset: check endpoint null in gigaset_probe
Subsystems (2)
PATCH 1/1 isdn/gigaset: check endpoint null in gigaset_probe
This fixed the potential reference NULL pointer while using variable endpoint.
Reported-by: syzbot+35b1c403a14f5c89eba7 at syzkaller.appspotmail.com Tested by syzbot:
https://groups.google.com/d/msg/syzkaller-bugs/wnHG8eRNWEA/Qn2HhjNdBgAJ
--- drivers/isdn/gigaset/usb-gigaset.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/isdn/gigaset/usb-gigaset.c +9 -0
@@ -703,6 +703,10 @@ static int gigaset_probe(struct usb_interface *interface,usb_set_intfdata (interface, cs); endpoint = &hostif->endpoint[0 ].desc; +if (!endpoint) { +dev_err (cs->dev,"Couldn't get control endpoint\n" ); +return -ENODEV ; + } buffer_size =le16_to_cpu (endpoint->wMaxPacketSize); ucs->bulk_out_size = buffer_size;
@@ -722,6 +726,11 @@ static int gigaset_probe(struct usb_interface *interface, } endpoint = &hostif->endpoint[1 ].desc; +if (!endpoint) { +dev_err (cs->dev,"Endpoint not available\n" ); + retval = -ENODEV ; + goto error; + } ucs->busy =0 ;
Signature · 1 line
2.20.1
Phong Tran schreef op vr 26-07-2019 om 20:35 [+0700]:
Quoted 10 lines
This fixed the potential reference NULL pointer while using variable endpoint.
Reported-by: syzbot+35b1c403a14f5c89eba7 at syzkaller.appspotmail.com Tested by syzbot:
https://groups.google.com/d/msg/syzkaller-bugs/wnHG8eRNWEA/Qn2HhjNdBgAJSigned-off-by Phong Tran <tranmanphong at gmail.com>--- drivers/isdn/gigaset/usb-gigaset.c | 9 +++++++++
This is now drivers/staging/isdn/gigaset/usb-gigaset.c.
Quoted 7 lines
1 file changed, 9 insertions(+)drivers/isdn/gigaset/usb-gigaset.c +0
-0
drivers/isdn/gigaset/usb-gigaset.c static int gigaset_probe(struct usb_interface *interface, · line 709
Quoted 7 lines
drivers/isdn/gigaset/usb-gigaset.c +4
-0@@ -703,6 +703,10 @@ static int gigaset_probe(struct usb_interface *interface,usb_set_intfdata (interface, cs); endpoint = &hostif->endpoint[0 ].desc; +if (!endpoint) { +dev_err (cs->dev,"Couldn't get control endpoint\n" ); +return -ENODEV ; + }
When can this happen? Is this one of those bugs that one can only trigger with a specially crafted (evil) usb device?
Quoted 4 lines
drivers/isdn/gigaset/usb-gigaset.c +0
-0buffer_size =le16_to_cpu (endpoint->wMaxPacketSize); ucs->bulk_out_size = buffer_size;@@ -722,6 +726,11 @@ static int gigaset_probe(struct usb_interface *interface, }
drivers/isdn/gigaset/usb-gigaset.c static int gigaset_probe(struct usb_interface *interface, · line 736
Quoted 10 lines
drivers/isdn/gigaset/usb-gigaset.c +5
-0endpoint = &hostif->endpoint[1 ].desc; +if (!endpoint) { +dev_err (cs->dev,"Endpoint not available\n" ); + retval = -ENODEV ; + goto error; + } ucs->busy =0 ;
Please note that I'm very close to getting cut off from the ISDN network, so the chances of being able to testi this on a live system are getting small.
Thanks,
Paul Bolle
Quoted 8 lines · Paul Bolle
Phong Tran schreef op vr 26-07-2019 om 20:35 [+0700]:
Quoted 7 lines
This fixed the potential reference NULL pointer while using variable endpoint.
Reported-by: syzbot+35b1c403a14f5c89eba7 at syzkaller.appspotmail.com Tested by syzbot:
https://groups.google.com/d/msg/syzkaller-bugs/wnHG8eRNWEA/Qn2HhjNdBgAJ
Quoted 5 lines
Quoted 3 lines
Signed-off-by Phong Tran <tranmanphong at gmail.com>--- drivers/isdn/gigaset/usb-gigaset.c | 9 +++++++++This is now
drivers/staging/isdn/gigaset/usb-gigaset.c.
this patch was created base on branch kasan/usb-fuzzer-usb-testing-2019.07.11 [1]
I did not notice about the driver was moved to staging.
Quoted 10 lines
Quoted 10 lines
1 file changed, 9 insertions(+)drivers/isdn/gigaset/usb-gigaset.c +0
-0@@ -703,6 +703,10 @@ static int gigaset_probe(struct usb_interface *interface,usb_set_intfdata (interface, cs);
Quoted 9 lines
drivers/isdn/gigaset/usb-gigaset.c static int gigaset_probe(struct usb_interface *interface, · line 709
Quoted 5 lines
drivers/isdn/gigaset/usb-gigaset.c +4
-0endpoint = &hostif->endpoint[0 ].desc; +if (!endpoint) { +dev_err (cs->dev,"Couldn't get control endpoint\n" ); +return -ENODEV ; + }When can this happen? Is this one of those bugs that one can only trigger with a specially crafted (evil) usb device?
Yes, in my understanding, this only happens with random test of syzbot.
Quoted 12 lines
Quoted 12 lines
drivers/isdn/gigaset/usb-gigaset.c +5
-0buffer_size =le16_to_cpu (endpoint->wMaxPacketSize); ucs->bulk_out_size = buffer_size;@@ -722,6 +726,11 @@ static int gigaset_probe(struct usb_interface *interface, } endpoint = &hostif->endpoint[1 ].desc; +if (!endpoint) { +dev_err (cs->dev,"Endpoint not available\n" ); + retval = -ENODEV ; + goto error; + }
Quoted 6 lines
drivers/isdn/gigaset/usb-gigaset.c static int gigaset_probe(struct usb_interface *interface, · line 736
Quoted 2 lines
drivers/isdn/gigaset/usb-gigaset.c +0
-0ucs->busy =0 ;Please note that I'm very close to getting cut off from the ISDN network, so the chances of being able to testi this on a live system are getting small.
This bug can be invalid now. Do you agree?
There is an instruction to report invalid bug to syzbot [2].
Quoted 5 lines
Thanks,
Paul Bolle
[1]
https://github.com/google/kasan/commits/usb-fuzzer-usb-testing-2019.07.11
[2]
https://github.com/google/syzkaller/blob/master/docs/syzbot.md#communication-with-syzbot
Thanks,
Phong
Hi Phong,
Phong Tran schreef op za 27-07-2019 om 08:56 [+0700]:
Quoted 19 lines · Paul Bolle
Quoted 8 lines
Phong Tran schreef op vr 26-07-2019 om 20:35 [+0700]:
Quoted 7 lines
drivers/isdn/gigaset/usb-gigaset.c +0
-0@@ -703,6 +703,10 @@ static int gigaset_probe(struct usb_interface *interface,usb_set_intfdata (interface, cs);Quoted 9 lines
drivers/isdn/gigaset/usb-gigaset.c static int gigaset_probe(struct usb_interface *interface, · line 709
Quoted 5 lines
drivers/isdn/gigaset/usb-gigaset.c +4
-0endpoint = &hostif->endpoint[0 ].desc; +if (!endpoint) { +dev_err (cs->dev,"Couldn't get control endpoint\n" ); +return -ENODEV ; + }When can this happen? Is this one of those bugs that one can only trigger with a specially crafted (evil) usb device?
Quoted 1 line
Yes, in my understanding, this only happens with random test of syzbot.
Looking at this again, I note the code is taking the address of a struct usb_endpoint_descriptor that's stored somewhere in memory. That address can't be NULL, can it?
So I haven't even looked at the fuzzer's report here, but I don't see how this patch could help. It only adds dead code. Am I missing something and should I drink even more coffee this Saturday morning?
Quoted 9 lines
Quoted 7 lines
drivers/isdn/gigaset/usb-gigaset.c static int gigaset_probe(struct usb_interface *interface, · line 726
Quoted 4 lines
drivers/isdn/gigaset/usb-gigaset.c +0
-0buffer_size =le16_to_cpu (endpoint->wMaxPacketSize); ucs->bulk_out_size = buffer_size;@@ -722,6 +726,11 @@ static int gigaset_probe(struct usb_interface *interface,Please note that I'm very close to getting cut off from the ISDN network, so the chances of being able to testi this on a live system are getting small.
This bug can be invalid now. Do you agree?
It's just that your patch arrived while I was busy doing my last ever test of the gigaset driver. So please don't expect me to put much time in this report (see
https://lwn.net/ml/linux-kernel/20190726220541.28783-1-pebolle%40tiscali.nl/
).
Thanks,
Paul Bolle