lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1593658371.23885.16.camel@mhfsdcap03>
Date:   Thu, 2 Jul 2020 10:52:51 +0800
From:   Chunfeng Yun <chunfeng.yun@...iatek.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC:     Felipe Balbi <felipe.balbi@...ux.intel.com>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Markus Elfring <Markus.Elfring@....de>,
        <linux-usb@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-mediatek@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [V2 PATCH] usb: mtu3: fix NULL pointer dereference

On Wed, 2020-07-01 at 13:58 +0200, Greg Kroah-Hartman wrote:
> On Tue, Jun 30, 2020 at 03:42:22PM +0800, Chunfeng Yun wrote:
> > Some pointers are dereferenced before successful checks.
> > 
> > Reported-by: Markus Elfring <Markus.Elfring@....de>
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@...iatek.com>
> > ---
> > v2: nothing changed, but abandon another patch
> > ---
> >  drivers/usb/mtu3/mtu3_gadget.c | 25 ++++++++++++++++++-------
> >  1 file changed, 18 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
> > index f93732e..1689ca8 100644
> > --- a/drivers/usb/mtu3/mtu3_gadget.c
> > +++ b/drivers/usb/mtu3/mtu3_gadget.c
> > @@ -332,14 +332,21 @@ static int mtu3_gadget_queue(struct usb_ep *ep,
> >  
> >  static int mtu3_gadget_dequeue(struct usb_ep *ep, struct usb_request *req)
> >  {
> > -	struct mtu3_ep *mep = to_mtu3_ep(ep);
> > -	struct mtu3_request *mreq = to_mtu3_request(req);
> > +	struct mtu3_ep *mep;
> > +	struct mtu3_request *mreq;
> >  	struct mtu3_request *r;
> > +	struct mtu3 *mtu;
> >  	unsigned long flags;
> >  	int ret = 0;
> > -	struct mtu3 *mtu = mep->mtu;
> >  
> > -	if (!ep || !req || mreq->mep != mep)
> > +	if (!ep || !req)
> > +		return -EINVAL;
> 
> How will either of those ever be NULL?  The kernel will not call this
> function with either of them being NULL, right?
Yes, I find all class drivers already ensure they are not NULL.

> 
> > +
> > +	mep = to_mtu3_ep(ep);
> > +	mtu = mep->mtu;
> > +
> > +	mreq = to_mtu3_request(req);
> > +	if (mreq->mep != mep)
> >  		return -EINVAL;
> >  
> >  	dev_dbg(mtu->dev, "%s : req=%p\n", __func__, req);
> > @@ -373,8 +380,8 @@ static int mtu3_gadget_dequeue(struct usb_ep *ep, struct usb_request *req)
> >   */
> >  static int mtu3_gadget_ep_set_halt(struct usb_ep *ep, int value)
> >  {
> > -	struct mtu3_ep *mep = to_mtu3_ep(ep);
> > -	struct mtu3 *mtu = mep->mtu;
> > +	struct mtu3_ep *mep;
> > +	struct mtu3 *mtu;
> >  	struct mtu3_request *mreq;
> >  	unsigned long flags;
> >  	int ret = 0;
> > @@ -382,6 +389,9 @@ static int mtu3_gadget_ep_set_halt(struct usb_ep *ep, int value)
> >  	if (!ep)
> >  		return -EINVAL;
> 
> Same here, how can that ever happen?
Maybe when the class driver has something wrong:)

You mean it's better to remove these unnecessary checks?

Thanks

> 
> >  
> > +	mep = to_mtu3_ep(ep);
> > +	mtu = mep->mtu;
> > +
> >  	dev_dbg(mtu->dev, "%s : %s...", __func__, ep->name);
> >  
> >  	spin_lock_irqsave(&mtu->lock, flags);
> > @@ -422,11 +432,12 @@ static int mtu3_gadget_ep_set_halt(struct usb_ep *ep, int value)
> >  /* Sets the halt feature with the clear requests ignored */
> >  static int mtu3_gadget_ep_set_wedge(struct usb_ep *ep)
> >  {
> > -	struct mtu3_ep *mep = to_mtu3_ep(ep);
> > +	struct mtu3_ep *mep;
> >  
> >  	if (!ep)
> >  		return -EINVAL;
> 
> Again, same here.
> 
> thanks,
> 
> greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ