Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1702982rwd; Tue, 16 May 2023 23:26:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6tkYRh5OrbyMEz9gRBGkAmcm9GolT064yjUvlkTTrCflI34uXOV0ZYlnzrpiEErLHM4Hly X-Received: by 2002:a17:902:e842:b0:1ab:17dc:d495 with SMTP id t2-20020a170902e84200b001ab17dcd495mr54906558plg.27.1684304803048; Tue, 16 May 2023 23:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684304803; cv=none; d=google.com; s=arc-20160816; b=THL0SAAWnh/RLOHNRKgFj1rOsm9n+zVLS84NaNBKQOkR09tmmLgKHOnAj6vhNDbuPL byLh7JLKdZ/XtJhyzEft8NhcAwOsB7XfM4w3PpAIIuZZXyeD0CYvSp3wU0jLj9E+VoKv pcF6zMF24BlRhx+0NoQ6SVYRYHKRrUMUpnIuJgnpc58rqNIjb4nRKh+H+LLtw3+QttRy AWY/DUi9p+CT7yf82rQXjeZmJY7f0cmPu7PCQD1iJ+ISTBem+Vs22HG4kpeKmmkr0neU 25ApMFeSfJcbMEsgpO+eDX99RItdEXrrft6FFXu4Y1GG/qq+ihdoDM84jBaIjuJ2+c9p VGrw== 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=6Yrk/M1EbXl/kX00xJrpSXS6oPhvx6jBCa0pOVA/Fvc=; b=XfupmnbPoMu3ZgrMX6op8Hq8Y2CImX5i3NN/NJEzHsYDpIBlVSCXFWAHc8A/QIO2mW kuhaenuRCfAUQjG/dRMumU8OJUmT2tC8LfS0ZJzP75rZKSBQVv4WIhVkVYC18S9p8TRF +RuVs9zs/Mtq5NpZ5RB4kZaLJGU/Ltjydfpk8733nnGuQBCFkQUrmmwWyAEQeDko6Juc 4ECDJF4Ka/Vw50AQlWdGbjFkjonnUScDVtQQVhqEGbwf1NjqL6+ucT5ebZMNa6VVAoXK 0QZM28d+GVxIj0fOl3Y+rKJH+XQVPaqkJ0AmHdCfy9FAox2L9eLURgGU43EoH3O9lZgA cshw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=QLDKcIxh; 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 l1-20020a17090270c100b001ae2aa44a98si4306735plt.265.2023.05.16.23.26.30; Tue, 16 May 2023 23:26:43 -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=QLDKcIxh; 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 S232614AbjEQGXE (ORCPT + 99 others); Wed, 17 May 2023 02:23:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232580AbjEQGXD (ORCPT ); Wed, 17 May 2023 02:23:03 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C7972D4C; Tue, 16 May 2023 23:23:02 -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=6Yrk/M1EbXl/kX00xJrpSXS6oPhvx6jBCa0pOVA/Fvc=; b=QLDKcIxhaZeTjAcqCHut7E8taM v7znFgRP6KTVpBFix3YkEYzXxV40cbqE+nriHreHGbeq1lVmYHPi9gbGyfalBYM8m/kJRf29g2TGj 6288yslVoRO2W20wdV22BmtyVcK5CbVSujD6TcvFeIZzdYpF+plAfgYIAThSlN2gvTcFC4a+uAt/4 HNmGtNjgjK0Se3xZA0LoYQ9Y5cgnzmKumNV1kq/ACjaORyilNCwsGOrbZdk0ULsLamcM+t0dEMI1z nzK0Le7jU2Sp+7r+boAnqrz6EUhmfqY+HeAA20EJo41stcXNd3CZctwDtd95HnD7vM/K15OR3U5BP G0cYmEWw==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pzAYq-008QEK-1i; Wed, 17 May 2023 06:22:56 +0000 Date: Tue, 16 May 2023 23:22:56 -0700 From: Christoph Hellwig To: Ruihan Li Cc: linux-mm@kvack.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Pasha Tatashin , David Hildenbrand , Matthew Wilcox , Andrew Morton , Christoph Hellwig , Alan Stern , Greg Kroah-Hartman , syzbot+fcf1a817ceb50935ce99@syzkaller.appspotmail.comm, stable@vger.kernel.org Subject: Re: [PATCH v2 1/4] usb: usbfs: Enforce page requirements for mmap Message-ID: References: <20230515130958.32471-1-lrh2000@pku.edu.cn> <20230515130958.32471-2-lrh2000@pku.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230515130958.32471-2-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 Mon, May 15, 2023 at 09:09:55PM +0800, Ruihan Li wrote: > To address these issues, this patch introduces hcd_alloc_coherent_pages, > which addresses the above two problems. Specifically, > hcd_alloc_coherent_pages uses gen_pool_dma_alloc_align instead of > gen_pool_dma_alloc to ensure that the memory is page-aligned. To replace > kmalloc, hcd_alloc_coherent_pages directly allocates pages by calling > __get_free_pages. This looks reasonable in that it fixes the bug. But I really don't like how it makes the mess of USB allocation APIs even messier :P Not really your faul, but someone really needs to look into the usb memory allocators and DMA mapping, which is tied to that and just as bad.