Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp578457ybe; Fri, 13 Sep 2019 02:44:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyG6Ezit5xLhoAKbl2sXS0h7SjHR+xeqGwJ2szlnbJuM7hO8hbpvvT+m6Z4mavpv5FYlhW8 X-Received: by 2002:a50:b582:: with SMTP id a2mr31195363ede.98.1568367896003; Fri, 13 Sep 2019 02:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568367895; cv=none; d=google.com; s=arc-20160816; b=EUUJGWGX1qz/IZ9buTv2eKcQUFj4oaImmHPeQxQhmYPQdbmOttGc74OTwyFkCv8juO QNd6o8ZffmsA1YAmaFZcQ+B3Df8cIibKYDCcbMAEMid2BEsfDYxL2g4IIS6IJZwHrnZI B6r7QoiZXaiVNXXc5nlqalHmB6+mYshJdslc5DR2vw1gm9xF/B7KEr7C/CsRgpcDk9jA n+jM2pqzmLjrWOXYdC35L59KKJ2HtIpqW7TpIMtUWwXfW3ceS/G2GbYgWdfd4O9Xoslf sg+kvjXAM6TmNigePCuSowHsA1fRoM11dJ0r2ve0UUyUWR+5oDN4tW2zYNA36sJhipnG Rfhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=0wZRdSHIeheVxa4DE7SyQMfDWHvTTN3LMA+T1b8qSjs=; b=DyGV/Is7ozAGIqzZxKc5ivpZfOpDE7KstKJU7BwyMJW76Y9nY+p7sNhO7wkUNzMsEN T6Nc7goroL0/V1dydTzTGs0jBGnAHt10F/xk79wq26q8CxeA2/+cjX6X1OFZMnWTFgrs A+xH4FhGVN4lTXcCUU8hxwN91lh3nhqNZjekl/cv5wjIbyyyMSoL1U3+rqWr1wgXoCix qHDHpNvQ+Upt3DdM9RceIeI4uxBY4ZHJsdn7uiyhvQU17HYgEVzvdTP+WsLb6SmFe3pa 1KR8ioVAh3ZlR+IgpBkl6KjN01LE0fYrv99cJaIbY2Hg9moTq5l7oQlfvZuA6Ut5WFLi snwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o56si17572340edc.349.2019.09.13.02.44.32; Fri, 13 Sep 2019 02:44:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727856AbfIMHef (ORCPT + 99 others); Fri, 13 Sep 2019 03:34:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59436 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725775AbfIMHee (ORCPT ); Fri, 13 Sep 2019 03:34:34 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6108680F7C for ; Fri, 13 Sep 2019 07:34:34 +0000 (UTC) Received: by mail-wm1-f71.google.com with SMTP id r187so729758wme.0 for ; Fri, 13 Sep 2019 00:34:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0wZRdSHIeheVxa4DE7SyQMfDWHvTTN3LMA+T1b8qSjs=; b=Itw4+YjeU2WKqW8xK3jBei8nhxLfgKxzg8PrTZ0Z8RyyAODWDPWWzKX2xH14Ll9nyQ +U8KEoXFByeYHw/TErUwgKFuR/PwAAvLmrDXqjIF/a8x1wzzhT4JDzwa/AVyWW7OUulf CYbnLl9ULdbUlM1xy9Sc79u+HehHNxwMuklZBlHZDvDeYtxr00/K3GyEC1Z6nNZpG/PI laD0/q+xyBbrLPbVNFUyXCiZl14CVgRCJaeIfkakHpyw1NkMPPxUKLFKRK/AaYqkCXuT dykTpdeBGWbWm6g/GzV0zg4NS0No/r6r4KfOaTYapAcHhKFu8vN48ccUwrmDn1Z2roM+ wdCg== X-Gm-Message-State: APjAAAWElIw09lVV9QOYMob4HiZNfq4eR1tRCeuETWUMok0P5I6femGz 0KahNGKz+tzeWY1u2UrR8QhkNEncPBdZnAdN5ebYJr5OspyhXtvZNM0mVUO8KNTTFAE6px2fHzX NjssiUz/0A01hJSHuCRz0OEbI X-Received: by 2002:a5d:49c7:: with SMTP id t7mr6515890wrs.229.1568360072890; Fri, 13 Sep 2019 00:34:32 -0700 (PDT) X-Received: by 2002:a5d:49c7:: with SMTP id t7mr6515852wrs.229.1568360072601; Fri, 13 Sep 2019 00:34:32 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:3166:d768:e1a7:aab8? ([2001:b07:6468:f312:3166:d768:e1a7:aab8]) by smtp.gmail.com with ESMTPSA id l1sm33488980wrb.1.2019.09.13.00.34.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Sep 2019 00:34:32 -0700 (PDT) Subject: Re: KASAN: slab-out-of-bounds Read in handle_vmptrld To: Greg Kroah-Hartman Cc: Vitaly Kuznetsov , kvm@vger.kernel.org, bp@alien8.de, carlo@caione.org, catalin.marinas@arm.com, devicetree@vger.kernel.org, hpa@zytor.com, jmattson@google.com, joro@8bytes.org, khilman@baylibre.com, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, mingo@redhat.com, narmstrong@baylibre.com, rkrcmar@redhat.com, robh+dt@kernel.org, sean.j.christopherson@intel.com, syzkaller-bugs@googlegroups.com, tglx@linutronix.de, wanpengli@tencent.com, will.deacon@arm.com, x86@kernel.org, syzbot , Dmitry Vyukov , USB list References: <000000000000a9d4f705924cff7a@google.com> <87lfutei1j.fsf@vitty.brq.redhat.com> <5218e70e-8a80-7c5f-277b-01d9ab70692a@redhat.com> <20190913044614.GA120223@kroah.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: Date: Fri, 13 Sep 2019 09:34:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190913044614.GA120223@kroah.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/09/19 06:46, Greg Kroah-Hartman wrote: > USB drivers expect kmalloc to return DMA-able memory. I don't know > about specific alignment issues, that should only an issue for the host > controller being used here, which you do not say in the above list. I have no idea, this is just the analysis of a syzkaller report. From the backtrace, it's one that ends up calling kmalloc; all of them should have the same issue with KASAN. The specific alignment requirement for this bug comes from this call in usbdev_mmap: if (remap_pfn_range(vma, vma->vm_start, virt_to_phys(usbm->mem) >> PAGE_SHIFT, size, vma->vm_page_prot) < 0) { > We have had some reports that usbdev_mmap() does not do the "correct > thing" for all host controllers, but a lot of the DMA work that is in > linux-next for 5.4-rc1 should have helped resolve those issues. What > tree are you seeing these bug reports happening from? It's in master, but the relevant code is the same in linux-next; in fact in this case there is no DMA involved at all. hcd_buffer_alloc hits the case "some USB hosts just use PIO". On those host controllers, it should be reproducible with just this: diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 7fcb9f782931..cc0460730bce 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -905,9 +905,12 @@ EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor); void *usb_alloc_coherent(struct usb_device *dev, size_t size, gfp_t mem_flags, dma_addr_t *dma) { + void *buf; if (!dev || !dev->bus) return NULL; - return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); + buf = hcd_buffer_alloc(dev->bus, size, mem_flags, dma); + WARN_ON_ONCE(virt_to_phys(buf) & ~PAGE_MASK); + return buf; } EXPORT_SYMBOL_GPL(usb_alloc_coherent); and CONFIG_KASAN=y or possibly just CONFIG_DEBUG_SLAB=y. mmap-ing /dev/usb should warn if my analysis is correct. If you think the above patch makes sense, I can test it and submit it formally. Paolo