Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6992367rwr; Wed, 10 May 2023 02:12:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7hzQ365KafVqKFG7+39GyqKlsESmMuu6T4Qi0PsiOaUU4fravV73MTyVMlDpHguW1iwnKP X-Received: by 2002:a05:6a00:198a:b0:641:39cb:1716 with SMTP id d10-20020a056a00198a00b0064139cb1716mr22382830pfl.20.1683709940407; Wed, 10 May 2023 02:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683709940; cv=none; d=google.com; s=arc-20160816; b=ixZNJaFnbkL3cFTum1kGdVY4RzX+H7GA3WTokt3+9fPZzLYeulnvfUjFC/cntXAgbK fOxkXsGArPpa1YF2tCdSuPWILXLL8psqJJ9pdLAXRAgW9kfSqkp1h6K2A7sPVwgzoYMf Ip8wVR8mOeW0Bafdt1elnHRgI03aXeNO/1ftD25RWnXOlNZJnaLRBWm9FBBSfWQX7qvj aWok1/ho3LkHVIl848NJnk7LJPKS7AMgqYWny1zNMJJj0ekgOdPA6BQm/LiScTOslU4+ 37rC4mlviwF/Vk2nuM4eR/DKjC+HQOz7g6QnjZxdtEg2aJx2sYXZT0tghuW2sv02uRSx QjRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5fgX4Fhl0aSp9FXpCFf3QP/h9Q7cD/Xeogk7PFQTbxg=; b=XWFOq/596tNvFS82OOkRMZFi9qNGZFZSfUznvD1lO8Xajba8AtBWxRhiHhO8GL4LZu fE72CCFgzHcHgXEAPdnlaerK7jg06nonlTRZM5N54oq8/dSrGLdv4IQTEV1T9Vr0Ipzy gGmzyvZvcfYi5cueK2qHKT9xF17Lb/7r2TneROQQw0kaoBLRxllv+toCrYq86l6asgSc d0KZu78Q/P1b7b2xcU2VcQM0TtqmsTn2VALRwmTVTT85Utsqvh1Dv01r5DsFifpGx42B +lLdsURMkqS0b3frnPPel4BK9x1xz9pRPd1mKwKyFwL89xV4LoF7XiIR5fWx9kRWNKm6 gZ+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@pku.edu.cn header.s=dkim header.b=YOYEJbkx; 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=pku.edu.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k189-20020a6384c6000000b00502f0410410si3519659pgd.472.2023.05.10.02.12.08; Wed, 10 May 2023 02:12:20 -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 (test mode) header.i=@pku.edu.cn header.s=dkim header.b=YOYEJbkx; 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=pku.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236840AbjEJI4G (ORCPT + 99 others); Wed, 10 May 2023 04:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236813AbjEJI4E (ORCPT ); Wed, 10 May 2023 04:56:04 -0400 Received: from pku.edu.cn (mx19.pku.edu.cn [162.105.129.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27A9BE45; Wed, 10 May 2023 01:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pku.edu.cn; s=dkim; h=Received:From:To:Cc:Subject:Date: Message-Id:MIME-Version:Content-Transfer-Encoding; bh=5fgX4Fhl0a Sp9FXpCFf3QP/h9Q7cD/Xeogk7PFQTbxg=; b=YOYEJbkx3Q7PrqHtYF/iMqaE6I nBpO1/Vlr1JQA3ZxAOsPmiY6ekTTBJpPkhIMeuDCyc/Bdep4JpBSnZPepdASfwmV sJ9drPAkkk+QZQYyrEkOk0cxbZO6OHC32wmVK5S6jLBbyYSy70V0RUlL52ui0cSk pEMKBV+HjoXkx+cgQ= Received: from localhost.localdomain (unknown [10.7.101.92]) by front01 (Coremail) with SMTP id 5oFpogBnb2cIXFtkW9d5Ag--.63159S2; Wed, 10 May 2023 16:55:39 +0800 (CST) From: Ruihan Li To: linux-mm@kvack.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Pasha Tatashin , David Hildenbrand , Matthew Wilcox , Andrew Morton , Christoph Hellwig , Greg Kroah-Hartman , Ruihan Li Subject: [PATCH 0/4] Fix type confusion in page_table_check Date: Wed, 10 May 2023 16:55:23 +0800 Message-Id: <20230510085527.57953-1-lrh2000@pku.edu.cn> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: 5oFpogBnb2cIXFtkW9d5Ag--.63159S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw1fJw4ktrW7Jw4ftrWDJwb_yoW8XrW8p3 WUCr1YqF4rG3s3Jw1SkanYk34ruF4rG3y7CryIk3yY93s5Jr1IkFn3Wr13Za4kAryUGr15 KF4agry7Kr18Ja7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBY1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW0oVCq3wA2z4x0Y4vEx4A2 jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAac4AC62xK8xCEY4 vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02 628vn2kIc2xKxwCY02Avz4vE-syl42xK82IYc2Ij64vIr41l42xK82IY6x8ErcxFaVAv8V WkJr1UJwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF 04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7 CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUbHa0DUUUUU== X-CM-SenderInfo: yssqiiarrvmko6sn3hxhgxhubq/1tbiAgEEBVPy770DbwAVsI X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, 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 Recently, syzbot reported [1] ("kernel BUG in page_table_check_clear"). The root cause is that usbdev_mmap calls remap_pfn_range on kmalloc'ed memory, which leads to type confusion between struct page and slab in page_table_check. This series of patches fixes the usb side by avoiding mapping slab pages into userspace, and fixes the mm side by enforcing that all user-accessible pages are not slab pages. A more detailed analysis and some discussion of how to fix the problem can also be found in [1]. [1] https://lore.kernel.org/lkml/20230507135844.1231056-1-lrh2000@pku.edu.cn/T/ Cc: Pasha Tatashin Cc: David Hildenbrand Cc: Matthew Wilcox Cc: Andrew Morton Cc: Christoph Hellwig Cc: Greg Kroah-Hartman Ruihan Li (4): usb: usbfs: Enforce page requirements for mmap usb: usbfs: Use consistent mmap functions mm: page_table_check: Make it dependent on !DEVMEM mm: page_table_check: Ensure user pages are not slab pages Documentation/mm/page_table_check.rst | 18 ++++++++++++ drivers/usb/core/buffer.c | 41 +++++++++++++++++++++++++++ drivers/usb/core/devio.c | 15 +++++++--- include/linux/page-flags.h | 6 ++++ include/linux/usb/hcd.h | 5 ++++ mm/Kconfig.debug | 2 +- mm/page_table_check.c | 6 ++++ 7 files changed, 88 insertions(+), 5 deletions(-) -- 2.40.1