From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0E67C3A589 for ; Thu, 15 Aug 2019 14:37:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC20A206C1 for ; Thu, 15 Aug 2019 14:37:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731703AbfHOOhC (ORCPT ); Thu, 15 Aug 2019 10:37:02 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:57986 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1730084AbfHOOhC (ORCPT ); Thu, 15 Aug 2019 10:37:02 -0400 Received: (qmail 2247 invoked by uid 2102); 15 Aug 2019 10:37:01 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 15 Aug 2019 10:37:01 -0400 Date: Thu, 15 Aug 2019 10:37:01 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Jonathan Bell cc: Oliver Neukum , , Minas Harutyunyan Subject: Re: dwc2 / Raspberry Pi - hardware bug for small transfers results in memory corruption In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Thu, 15 Aug 2019, Jonathan Bell wrote: > On Thu, Aug 15, 2019 at 11:55 AM Oliver Neukum wrote: > > > > Am Mittwoch, den 14.08.2019, 16:59 +0100 schrieb Jonathan Bell: > > > As reported by one of our users here: > > > https://github.com/raspberrypi/linux/issues/3148 > > > > > > There is a bug when the dwc2 core receives USB data packets that are > > > between 1 and 4 bytes in length - 4 bytes are always written to memory > > > where the non-packet bytes are garbage. > > > > Hi, > > > > in which function does that happen? If your buffer cannot handle 4 > > bytes I cannot see how it copes with teh DMA rules. > > > In drivers/media/usb/uvc/uvc_ctrl.c:uvc_ctrl_populate_cache() and friends. > > The UVC driver passes in offsets into a struct uvc_control as the > "buffer" that usb_control_msg() fills. This sounds like a violation of the DMA rules. A buffer passed to usb_control_msg() must be allocated by kmalloc or equivalent, and it must not share a cache line with any other data values. Something in the middle of a larger struct is definitely not kosher. Alan Stern