Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5804977rwr; Tue, 9 May 2023 06:37:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5uY1h857yDBhcpH35EQY1P5IIG7CGGH4C/rkVA10s8Nhk7dOOCQ+NWDzjt/tnrgLW7drD3 X-Received: by 2002:a17:902:ce81:b0:1aa:efad:f2d4 with SMTP id f1-20020a170902ce8100b001aaefadf2d4mr18481352plg.63.1683639426718; Tue, 09 May 2023 06:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683639426; cv=none; d=google.com; s=arc-20160816; b=gxSWVJ6HkndVPm7iUYTgkN2kfFHVOqPsZgtqlIpHxHREe0IPdLfSp9YyQOV3DvM/m7 2IUrRWG4TPsYcjbdpBAXOVQwxrNajNEx6dP301yKqBnRyR+QPvLg+JOu2Biq/Z3I52ze TY8yqIXI/n9R7Bd6O9MQGdM13kDCtXA+cYbBA7pKWMTiD8DC0jcnIYJmeioM0aYDYMj5 d3gKqq+daOaC/ej/Uh2QyxcS/74oj9cP42qk31hPvIHE9LAjrTGgEl64zrech88oTi9v PWT/YsZsPUpIMK3k3qaB4GrNydrB+vJMuQISlsg0DlJT/F2rcag84Yox5igEOQqyDrrV CSww== 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=KkqdRlUqTfle/lYv4ZxNsnZATjCjThA8plTsZKPzERM=; b=xhMeBXbyfmJ3Q8hHIDbujdosS0tXQkEzb6zqxJD5pEU1p0214ax7qsUu5g7uafYXku fYBgOsyaBrM6C2sC0on6dJveHX/oUl7WQHY1/spwuSl7wugKhIjw2iAAk1DLpT4RN6+s YdWx++CnctP/oH9uDMNPFJt+pG7JBMj6Tl4vOBI2SunHBY5C23C549j4SYvOd/x+m2CJ WCujfwUjbwrjnwCCwY1TMTNX0KCTmvd2PI9XpG/pL4FYeVou0MkyjLpiIBY6+YK7DeDQ ILXfa8pCETM84n4SeWBI1HwTPldDAHYjiFQ/22CYzWkNk9W1f/+p+6S2S1JrI11Het5B hbUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=FBbYsSJD; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a170902bd4c00b001ac311fef9asi1426290plx.313.2023.05.09.06.36.54; Tue, 09 May 2023 06:37:06 -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=@infradead.org header.s=bombadil.20210309 header.b=FBbYsSJD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235296AbjEINZw (ORCPT + 99 others); Tue, 9 May 2023 09:25:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjEINZv (ORCPT ); Tue, 9 May 2023 09:25:51 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90B4C2D73; Tue, 9 May 2023 06:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KkqdRlUqTfle/lYv4ZxNsnZATjCjThA8plTsZKPzERM=; b=FBbYsSJDiapHHKmOXLJjPcHlfA 2b7UFlLrJM2/KG1rwYBEUmutob3kdAzgoMniGXUUy1YL64qvbxmGBESnIi6KWBlf2AarPUfZJbMXe RHh/+6ovolYDesxApYaOOV69N4ZFqBugnidcCDrLCUp4zraIg/KphUf/AGLkmvco8LE0baHsiiIH5 YCWKT7p4+J2kU+UA3Fe8u2WdLmCf2WdpkAzvBZrC0Iavymmc2vFlwT0aPizuD015Wxh06Yp8Gt485 v1SifxO1pisxS8h2ksTNDhhQ4kt5S3ELar5M+ZwlwMPwExrn/2TwGxgF3I+IrQt1a+2O0zf6Lf7FH QXMfVEXg==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pwNLa-003Ota-1B; Tue, 09 May 2023 13:25:42 +0000 Date: Tue, 9 May 2023 06:25:42 -0700 From: Christoph Hellwig To: Ruihan Li Cc: syzbot+fcf1a817ceb50935ce99@syzkaller.appspotmail.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, pasha.tatashin@soleen.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: usbdev_mmap causes type confusion in page_table_check Message-ID: 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: <20230507135844.1231056-1-lrh2000@pku.edu.cn> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 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.