From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755284AbcETAue (ORCPT ); Thu, 19 May 2016 20:50:34 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47268 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754325AbcETAud (ORCPT ); Thu, 19 May 2016 20:50:33 -0400 Date: Thu, 19 May 2016 17:50:31 -0700 From: Greg Kroah-Hartman To: Valdis Kletnieks Cc: Alan Stern , Andrey Ryabinin , Oliver Neukum , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH] - silence UBSAN complaint in ehci-hcd. Message-ID: <20160520005031.GA11921@kroah.com> References: <14469.1463692740@turing-police.cc.vt.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14469.1463692740@turing-police.cc.vt.edu> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 19, 2016 at 05:19:00PM -0400, Valdis Kletnieks wrote: > UBSAN throws a complaint: > > [ 2.418579] UBSAN: Undefined behaviour in drivers/usb/host/ehci-hub.c:877:47 > [ 2.418582] index -1 is out of range for type 'u32 [1]' > > though it's only on the hostpc[] part, not on the port_status[] on the > previous line which has the same exact index calculation. The root cause is > that the first declaration is port_status[0], which uses a GCC extension and > UBSAN is smart enough to realize the programmer is doing something > intentionally odd. > > However, the problematic declaration is hostpc[1], which doesn't have > the "I know what I'm doing" semantics of [0]. Change the declaration to match. > > Signed-Off-By: Valdis Kletnieks > > --- a/include/linux/usb/ehci_def.h 2015-01-06 01:04:24.342436706 -0500 > +++ b/include/linux/usb/ehci_def.h 2016-05-19 13:57:20.869304540 -0400 > @@ -180,11 +180,11 @@ struct ehci_regs { > * PORTSCx > */ > /* HOSTPC: offset 0x84 */ > - u32 hostpc[1]; /* HOSTPC extension */ > + u32 hostpc[0]; /* HOSTPC extension */ > #define HOSTPC_PHCD (1<<22) /* Phy clock disable */ > #define HOSTPC_PSPD (3<<25) /* Port speed detection */ Hm, this is odd, you really do want hostpc to be 1 u32 value, don't make it 0 please. If you walk off the end of hostpc, well, let's fix that properly. And are you sure this is needed? Is this a different issue from the other long thread right now that we finally got a patch for? thanks, greg k-h