Re: UBSAN whinge in ihci-hub.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 18 May 2016, Andrey Ryabinin wrote:

> 2016-05-18 17:40 GMT+03:00 Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>:
> 
> > All right, I'm getting very tired of all these bug reports.  Besides,
> > Andrey has a point: Unless you're Linus, arguing against the C standard
> > is futile.  (Even though the language dialect used in the kernel is not
> > standard C.)
> >
> > Does this patch make UBSAN happy?  The runtime overhead is minimal.
> >
> 
> It does. However, you could fool ubsan way more easy:
>              u32 __iomem     *hostpc_reg = ehci->regs->hostpc +
> (wIndex & 0xff) - 1;

Really?  That's a lot simpler.  But will it also fool gcc?  That is, 
will it prevent gcc from optimizing away the !wIndex tests below?

How about this patch?

Alan Stern



Index: usb-4.x/drivers/usb/host/ehci-hub.c
===================================================================
--- usb-4.x.orig/drivers/usb/host/ehci-hub.c
+++ usb-4.x/drivers/usb/host/ehci-hub.c
@@ -872,9 +872,10 @@ int ehci_hub_control(
 ) {
 	struct ehci_hcd	*ehci = hcd_to_ehci (hcd);
 	int		ports = HCS_N_PORTS (ehci->hcs_params);
-	u32 __iomem	*status_reg = &ehci->regs->port_status[
-				(wIndex & 0xff) - 1];
-	u32 __iomem	*hostpc_reg = &ehci->regs->hostpc[(wIndex & 0xff) - 1];
+	u32 __iomem	*status_reg = ehci->regs->port_status +
+				((wIndex & 0xff) - 1);
+	u32 __iomem	*hostpc_reg = ehci->regs->hostpc +
+				((wIndex & 0xff) - 1);
 	u32		temp, temp1, status;
 	unsigned long	flags;
 	int		retval = 0;

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux