Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5863211rwr; Tue, 9 May 2023 07:16:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4YzyByPZKduPXL1JUPVuQmjb2j8+mqtQeH684bT337KmFNq5ejZWzXrhLSnm4aLpuOs1Ti X-Received: by 2002:a05:6a20:914a:b0:f2:c2a3:39a with SMTP id x10-20020a056a20914a00b000f2c2a3039amr18815447pzc.61.1683641760840; Tue, 09 May 2023 07:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683641760; cv=none; d=google.com; s=arc-20160816; b=mV5S3/A+YBdjKNnHSQtDWx2o36Pq582UJOvNsN5fzgpInWd87Y7Lw1TjFEN+IUBMv0 tivA6hzeFMEkAiJ5RnxFM34iEUu5A8M2IS0ky8GRD9Vo1YFz5wogh1pd+dkYCsTXz5A+ BCo60/j7oNeIhsW3XzDfEOuGt7VhHg7MSZy/rQjrxCu1KCQaUO4uOQFzo+p+p/1Buv+N 71wtywhJxnQ0ZnxUHzhG88eW2B8DF0Ol3doZkNVik0bM8RJnOFuyVCeHrFXLwRmHayx0 4e9PCqH18bLu6O5AMufNCiOxBLjHqR6LLt6S+DDzmylceLGM/bPc/sGolTNKrv7GtVXr r8yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2vywYn4RmCVLAoap8lx8gWfnn7MwY1TH97r5zz9PtGI=; b=OBbyAKXXZcLvQE75iWAX86BLAbcTPOllKhCtR+FIF6xIaGOIFRgBxJWGyWylU8rKNf 5E17gXvqS2Gs0sFkm0kqm7aNvR21zvELkFhDgpWQfN6jSnFy7KOJ4U12hAWzhPi7BXUL i8Jtx0V4eQwRVKI+YAQfj0uS2LQFymbQwb8e1OzGEP7M7yyZsNSUq0SkzLtuewQh5znQ ZPvgu0Xmr3aSODER8dJBv4g33ITsfrOMA7j0mKeC9PFOEbWa0/SN75dyPxcLkcl4p3T+ 6CqZkkVTAovWuFuo926LTsugOvKCXuCjth0E8rbknbL5DyN8Rf7snuL1vMfCzf9MIwGA PIkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=moSfqhSO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020aa79aea000000b005a908acf446si2507354pfp.104.2023.05.09.07.15.44; Tue, 09 May 2023 07:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=moSfqhSO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235662AbjEIOBM (ORCPT + 99 others); Tue, 9 May 2023 10:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235430AbjEIOBI (ORCPT ); Tue, 9 May 2023 10:01:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 800AB2D58; Tue, 9 May 2023 07:01:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 02564646BA; Tue, 9 May 2023 14:01:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C9BEC433D2; Tue, 9 May 2023 14:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1683640866; bh=mj33fPqfFt4lD4T+X1wHRTl3U886tC9uw2mp+55gJvM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=moSfqhSOtlwaW3DesFw9Yd3yQt5Tk+EMUei/VbgLVPhXyhWvIb6o7+02NyLbqmfKK PmAYPR0Nygfx139UU9NT4Bz74V/nJIJZ80C6DpTJB0P4uDezHrtW4VPb3k74griyS1 lZHYnvd9BAiGzXdE5/Lj9MJmlCifUAEpoDg7L+LA= Date: Tue, 9 May 2023 16:01:02 +0200 From: Greg KH To: Christoph Hellwig Cc: Ruihan Li , syzbot+fcf1a817ceb50935ce99@syzkaller.appspotmail.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, pasha.tatashin@soleen.com, linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: usbdev_mmap causes type confusion in page_table_check Message-ID: <2023050934-launch-shifty-0bbb@gregkh> References: <000000000000258e5e05fae79fc1@google.com> <20230507135844.1231056-1-lrh2000@pku.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 09, 2023 at 06:25:42AM -0700, Christoph Hellwig wrote: > On Sun, May 07, 2023 at 09:58:44PM +0800, Ruihan Li wrote: > > static int usbdev_mmap(struct file *file, struct vm_area_struct *vma) > > { > > // ... > > mem = usb_alloc_coherent(ps->dev, size, GFP_USER | __GFP_NOWARN, > > &dma_handle); > > // ... > > if (hcd->localmem_pool || !hcd_uses_dma(hcd)) { > > if (remap_pfn_range(vma, vma->vm_start, > > virt_to_phys(usbm->mem) >> PAGE_SHIFT, > > usb_alloc_coherent and up in the DMA coherent allocator (usually > anyway), and you absolutely must never do a virt_to_phys or virt_to_page > on that return value. This code is a buggy as f**k. Odd, you gave it a reviewed-by: in commit a0e710a7def4 ("USB: usbfs: fix mmap dma mismatch") back in 2020 when it was merged as you said that was the way to fix this up. :) Do you have a better way to do it now that is more correct? Did some DMA changes happen that missed this codepath getting fixed up? thanks, gre gk-h