Re: [PATCH] usb: usbfs: fix crash in check_ctrlrecip()->usb_find_alt_setting()

From: Vladis Dronov
Date: Tue Sep 25 2018 - 14:55:17 EST


Hello, Alan, Andrey, all,

> > > (You'll be lucky if Linus doesn't see that. He yells at anybody who
> > > suggests adding BUG_ON for anything that doesn't completely crash

Now, may be not )

> > > How is this different from calling kfree() with a NULL argument?

It is not, it is the same case.

> > What about adding a WARN_ON()? It doesn't crash the kernel and it will
> > be detected and reported by syzbot.

Yes, that would be a great solution.

> Sure, we could do that. But would be the point?

We know when usb_find_alt_setting() callers do smth weird and go fix them.

> After c9a4cb204e9e, calling usb_find_alt_setting() with a NULL config is
> no more of a bug than calling kfree() with a NULL pointer.

Yes, exactly.

> You wouldn't want to put a WARN_ON in kfree(), would you?

Honestly, in the ideal world I would, again, to be aware when some code does
something weird so we know about it. But this world is this world, it needs
more performance to the throne of performance.

I have no other arguments except the above, please, feel free to not to accept
my patch.

Best regards,
Vladis Dronov | Red Hat, Inc. | Product Security Engineer