linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladis Dronov <vdronov@redhat.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Andrey Konovalov <andreyknvl@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Oliver Neukum <oneukum@suse.com>,
	Hans de Goede <hdegoede@redhat.com>,
	syzkaller <syzkaller@googlegroups.com>,
	USB list <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	stable <stable@vger.kernel.org>
Subject: Re: [PATCH] usb: usbfs: fix crash in check_ctrlrecip()->usb_find_alt_setting()
Date: Wed, 26 Sep 2018 04:22:08 -0400 (EDT)	[thread overview]
Message-ID: <1046309093.16165115.1537950128159.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1809251600150.1517-100000@iolanthe.rowland.org>

Hello, Alan,

> Now consider the case at hand: the call to usb_find_alt_setting() from
> check_ctrlrecip().  In this case ps->dev->actconfig being NULL doesn't
> indicate an error or a bug; it merely indicates that the user is trying
> to send a control request to a device which happens to be unconfigured,
> which is a perfectly valid thing to do.  Therefore it shouldn't require
> any special handling at the call site.
> 
> Alan Stern

Thank you for the explanation and a detailed response.

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

----- Original Message -----
> From: "Alan Stern" <stern@rowland.harvard.edu>
> To: "Vladis Dronov" <vdronov@redhat.com>
> Cc: "Andrey Konovalov" <andreyknvl@google.com>, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, "Oliver Neukum"
> <oneukum@suse.com>, "Hans de Goede" <hdegoede@redhat.com>, "syzkaller" <syzkaller@googlegroups.com>, "USB list"
> <linux-usb@vger.kernel.org>, "LKML" <linux-kernel@vger.kernel.org>, "stable" <stable@vger.kernel.org>
> Sent: Tuesday, September 25, 2018 10:44:14 PM
> Subject: Re: [PATCH] usb: usbfs: fix crash in check_ctrlrecip()->usb_find_alt_setting()
> 
> On Tue, 25 Sep 2018, Vladis Dronov wrote:
> 
> > > > 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.
> 
> But is it really worthwhile?  In terms of catching bugs, this would
> help in only one situation: when the programmer thinks the argument
> should always be non-NULL because a NULL argument indicates a bug.
> Such situations seem to be relatively rare, and we can handle them by
> inserting a WARN_ON() at the call site if need be.
> 
> So it's a choice between:
> 
>      1. Putting a single test for NULL in the function being called,
> 	together with WARN_ON() at a small number of call sites, or
> 
>      2. Putting a WARN_ON() (or allowing a crash) in the function being
> 	called, together with tests for NULL at a potentially large
> 	number of call sites.
> 
> 1 has two advantages over 2.  First, it involves adding less code
> overall.  Second, it doesn't require the programmer to remember to add
> special code (a test or a WARN_ON) in situation where it doesn't
> matter -- presumably the majority of them.
> 

      reply	other threads:[~2018-09-26  8:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25 12:22 [PATCH] usb: usbfs: fix crash in check_ctrlrecip()->usb_find_alt_setting() Vladis Dronov
2018-09-25 14:14 ` Alan Stern
2018-09-25 14:55   ` Vladis Dronov
2018-09-25 15:15     ` Alan Stern
2018-09-25 15:17       ` Andrey Konovalov
2018-09-25 17:54         ` Alan Stern
2018-09-25 18:55           ` Vladis Dronov
2018-09-25 20:44             ` Alan Stern
2018-09-26  8:22               ` Vladis Dronov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1046309093.16165115.1537950128159.JavaMail.zimbra@redhat.com \
    --to=vdronov@redhat.com \
    --cc=andreyknvl@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=syzkaller@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).