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=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 4553CC54FD0 for ; Mon, 27 Apr 2020 13:59:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E9347206B9 for ; Mon, 27 Apr 2020 13:59:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YVfAfZvu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9347206B9 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 86E528E0007; Mon, 27 Apr 2020 09:59:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81E408E0001; Mon, 27 Apr 2020 09:59:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E69B8E0007; Mon, 27 Apr 2020 09:59:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id 57B9C8E0001 for ; Mon, 27 Apr 2020 09:59:29 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0BB5A180AD806 for ; Mon, 27 Apr 2020 13:59:29 +0000 (UTC) X-FDA: 76753792458.28.sand86_8cf30aa4c821a X-HE-Tag: sand86_8cf30aa4c821a X-Filterd-Recvd-Size: 6875 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Mon, 27 Apr 2020 13:59:28 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id h4so6392115wmb.4 for ; Mon, 27 Apr 2020 06:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=QhAcqsYVXaqZhcLoSViqs2GuIXaiezrb4zt+zmcsSY0=; b=YVfAfZvu9JpAdstItbBL+If3/15LYvKfM1CVZRutoQzyHSsyoNSjiavTfcb910qkGC jTdVKfq6HfDQMXSvP6ZjoyOaiAHPVcFty8rnYJbuN6hm/N9f6uN8yJGMiW30tQCFR9/T Gov8KLGHb1j0YB4byyWcwgSHNRj6BGqJgHBTkLcuVcS5HBoebhBpeYOkOCfV4J7VHMul XpqVF2bkkvW+zBoIKO7zGwCwphjtLFn8Q3BgMd6y0AiSoXh3i7WCCWNKPpqZ5rJDIJgz jo146vc3r+gJOe8trWsSa0gFO9jS+RY0gdtRngAbx+1zh3FcsE+cD9/obmpQpZwtfRWU o1NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=QhAcqsYVXaqZhcLoSViqs2GuIXaiezrb4zt+zmcsSY0=; b=qn1HOSb8FQxInbe3ev7MQM2Xhovr3cobifRmhgi4v95vzLjiLQpoDE/LlDJcg3Kazs mNx7H1qVZIrwo/D3IbFtpgc4wWe/2PPnjtY3fx8OHV+Y3N8pHBnBd4cyguaANOIX1Eei M66/bn86DSQmz14oU/dL8JOJJxxhs9mB/VYNmR/4/qK7uRh2JtC5WtZVV5dwisGh4rVu /yAxcI+uIakCo0vyBHhNXyL9G2T5i0n7FouFOpH38mn6ALgdFAQLrjt34dt8RwG+VTVZ gPUOUyuPd3n0O+cXbOWhW8IeSypXWH+eQJ8zcJQ7QSFSaf8FEn/XzAd5WFnE1V/VWbmr UC8g== X-Gm-Message-State: AGi0PuZ37oEUZH2Pz8Drrfo2sA7Sj4MIBhT7B7mdEdDlDqYliCUwI+io 70d0donQhtv/fy2Htl1ruajD70iqA+Qj2+3T3MEctg== X-Google-Smtp-Source: APiQypIdLMIJEI8JmYB4gT1be8VsLio3iW/R2183FzZGXMvL71eYPxz/hzZAxI16mLdaxCfr1hEseSa5gB6wMu/MQ08= X-Received: by 2002:a1c:6787:: with SMTP id b129mr27572749wmc.165.1587995966884; Mon, 27 Apr 2020 06:59:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Alexander Potapenko Date: Mon, 27 Apr 2020 15:59:15 +0200 Message-ID: Subject: Re: [PATCH v5 20/38] kmsan: handle memory sent to/from USB To: Alan Stern Cc: Andrey Konovalov , Andrew Morton , Greg Kroah-Hartman , Eric Dumazet , Wolfram Sang , Petr Mladek , Vegard Nossum , Dmitry Vyukov , Marco Elver , Linux Memory Management List , Alexander Viro , Andreas Dilger , Andrey Ryabinin , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Christoph Hellwig , Christoph Hellwig , "Darrick J. Wong" , "David S. Miller" , Dmitry Torokhov , Eric Biggers , Eric Van Hensbergen , Harry Wentland , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jason Wang , Jens Axboe , Marek Szyprowski , Mark Rutland , "Martin K. Petersen" , Martin Schwidefsky , Matthew Wilcox , "Michael S . Tsirkin" , Michal Hocko , Michal Simek , Qian Cai , Randy Dunlap , Robin Murphy , Sergey Senozhatsky , Steven Rostedt , Takashi Iwai , "Theodore Ts'o" , Thomas Gleixner , Vasily Gorbik Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Apr 14, 2020 at 10:45 PM Alan Stern wro= te: > > On Tue, 14 Apr 2020, Andrey Konovalov wrote: > > > On Tue, Apr 14, 2020 at 5:50 PM Alan Stern = wrote: > > > > This has got a couple of problems. > > > > > > Firstly, for control URBs it doesn't check urb->setup_packet, which > > > should always be initialized regardless of the direction because it > > > always gets sent to the device. > > > > Ah, yes, we actually had an info-leak report for a bug in the sound > > subsystem that was leaking data this way, which was misattributed to > > raw-gadget. This makes sense to add and seems quite easy. > > > > > Secondly, some URBs use scatter-gather transfers, and they don't alwa= ys > > > store the buffer address in urb->transfer_buffer (indeed, sometimes t= he > > > buffer is located outside of the kernel's address map). Instead they > > > use urb->sg and urb->num_sgs. To get an idea for how it all works, > > > look at usb_hcd_map_urb_for_dma() in hcd.c. > > > > Oh, this is something we need to look into. > > > > > Thirdly, the information we get back from the device doesn't always > > > cover the entire transfer buffer; sometimes the device sends less dat= a > > > than we asked for. Perhaps you don't care very much about this case. > > > > So you mean that we should look at actual_length rather than > > transfer_buffer_length when initializing memory that comes from the > > device? > > Yes, in theory. Isochronous transfers are difficult, because the data > doesn't have to be contiguous in memory. If you want to handle them > properly, you have to loop through the entries in the > urb->iso_frame_desc[] array and treat them individually. > Thanks! I'll take a closer look and will probably ask you more questions, as we're extensively fuzzing USB on syzbot. However for the first stage of upstreaming KMSAN I think we'd better drop USB checks to reduce the patch set. It has already become enormous and hard to review or manage. --=20 Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg