From: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
To: Alan Stern <stern@rowland.harvard.edu>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Oliver Neukum <oneukum@suse.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [PATCH] - silence UBSAN complaint in ehci-hcd.
Date: Thu, 19 May 2016 17:19:00 -0400 [thread overview]
Message-ID: <14469.1463692740@turing-police.cc.vt.edu> (raw)
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 <valdis.kletnieks@vt.edu>
--- 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 */
- u32 reserved5[16];
+ u32 reserved5[17];
/* USBMODE_EX: offset 0xc8 */
u32 usbmode_ex; /* USB Device mode extension */
next reply other threads:[~2016-05-19 23:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 21:19 Valdis Kletnieks [this message]
2016-05-20 0:50 ` [PATCH] - silence UBSAN complaint in ehci-hcd Greg Kroah-Hartman
2016-05-20 0:59 ` Valdis.Kletnieks
2016-05-20 14:37 ` Alan Stern
2016-05-20 14:34 ` Alan Stern
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=14469.1463692740@turing-police.cc.vt.edu \
--to=valdis.kletnieks@vt.edu \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=ryabinin.a.a@gmail.com \
--cc=stern@rowland.harvard.edu \
/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