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: <YbBGGI9wQenI4kP7@kroah.com>
Date:   Wed, 8 Dec 2021 06:43:52 +0100
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Alan Stern <stern@...land.harvard.edu>
Cc:     Guo Zhengkui <guozhengkui@...o.com>, Li Jun <jun.li@....com>,
        Kishon Vijay Abraham I <kishon@...com>,
        Andrey Konovalov <andreyknvl@...il.com>,
        Peter Chen <peter.chen@....com>,
        "open list:USB SUBSYSTEM" <linux-usb@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>, kernel@...o.com
Subject: Re: [PATCH] usb: core: hcd: fix bug: application of sizeof to pointer

On Tue, Dec 07, 2021 at 05:21:05PM -0500, Alan Stern wrote:
> On Tue, Dec 07, 2021 at 03:40:37PM +0100, Greg Kroah-Hartman wrote:
> > On Tue, Dec 07, 2021 at 09:53:47PM +0800, Guo Zhengkui wrote:
> > > Fix following error:
> > > ./drivers/usb/core/hcd.c:1284:38-44: ERROR:
> > > application of sizeof to pointer.
> > 
> > What generated this error?
> > 
> > > 
> > > Use sizeof(*vaddr) instead.
> > > 
> > > Signed-off-by: Guo Zhengkui <guozhengkui@...o.com>
> > > ---
> > >  drivers/usb/core/hcd.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> > > index 4d326ee12c36..996d5273cf60 100644
> > > --- a/drivers/usb/core/hcd.c
> > > +++ b/drivers/usb/core/hcd.c
> > > @@ -1281,7 +1281,7 @@ static int hcd_alloc_coherent(struct usb_bus *bus,
> > >  		return -EFAULT;
> > >  	}
> > >  
> > > -	vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr),
> > > +	vaddr = hcd_buffer_alloc(bus, size + sizeof(*vaddr),
> > 
> > I think you just broke the code.
> > 
> > Look at this closer and see what the function is doing with this buffer
> > and if you still think your patch is correct, please rewrite the
> > changelog text to explain why it is so (hint, just using the output of
> > coccinelle isn't ok.)
> 
> Although the patch is definitely wrong, the code could stand to be 
> improved.  The value stored at the end of the buffer is *vaddr_handle 
> converted to an unsigned long, but the space reserved for this value is 
> sizeof(vaddr) -- which doesn't make much sense since vaddr is a pointer 
> to unsigned char.  The code implicitly relies on the fact that unsigned 
> long takes up the same amount of space as a pointer.

Linux requires that an unsigned long is the same size as a pointer, so
this is not a new requirement that is unique to this function :)

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ