Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2043327rwd; Mon, 15 May 2023 06:37:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fgYrKvMxf7COVSrBN5AUmdC/A8izeALUlQRxVJJTOzfZAWDyRzuzLjkwfFEx4tSe/AWjp X-Received: by 2002:a05:6a00:22d3:b0:64a:a432:f313 with SMTP id f19-20020a056a0022d300b0064aa432f313mr16396239pfj.31.1684157848137; Mon, 15 May 2023 06:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684157848; cv=none; d=google.com; s=arc-20160816; b=x5JqbXq+vRK/fleH7qPi5+j7mAbM4ARc1p5meiOtvA2tLYXFatNWDWFPbdij7Gfjc+ 3dBDDKL2QHwO5kX9PFoelbZx17kGFBsAIp7xUd5vt2FdZNPZX1VtR0Q4Ty9aP4TL5N/f JO0iCFKfJkdTTQkQKlHBJmyKiUkfk+Pbk4wl/5S82KdQggemeUxh0TdIE/5ocO5/rr6R kVJMcsUHOC58o3C0Q9o8pJ/CuFw9QUM9GKGmmmVViEGzzqHQIYwMhdlDChAgsHVUAY1g nZkU2km2HMbJe3wgidJqwepfADIErEajVV6q+lqINomFwLwx1T1lvNzvr/zaJjmv/6xS 6RQQ== 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=7xP0On4kxeWWPTALWosP9FmQHvyKTJsqUxCPEueBxBA=; b=l9Wv9r2KlHOTSgc+Aqkc0q8nPcPhUdpXQjje6/SLwHiJkTMtKYnBfRnwnI3RusOZW/ I4p1tzJ4ftjP55+OY51BcLXhplWdVjOirPCWB0Lox1WlosexwZHlstg7fTKuC0ryrccI avdwIxcBZjbKLePsaAhsWGGGFDnz/mZB+GyzLQ0Oy0Bo4oA+J5y8PyScNK9CVh6JJET3 L0stKTPMSd4qcTex+Fj2El9f6T9bln6xTd+LHWnL1hH1AyRFM/bEfs+fQybNKufsiDV1 OJEo5yZptVd9xU1ofjmUSVBdTprDak9HApmo3+uEsgUqiwuRILeT0r4hwvBjfNLyDJx1 +3LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@pku.edu.cn header.s=dkim header.b=PyktA73T; 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 f27-20020aa7969b000000b00643b3155b67si17433376pfk.213.2023.05.15.06.37.15; Mon, 15 May 2023 06:37:28 -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=PyktA73T; 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 S241954AbjEONL1 (ORCPT + 99 others); Mon, 15 May 2023 09:11:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241718AbjEONKw (ORCPT ); Mon, 15 May 2023 09:10:52 -0400 Received: from pku.edu.cn (mx19.pku.edu.cn [162.105.129.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BF6972130; Mon, 15 May 2023 06:10:28 -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=7xP0On4kxe WWPTALWosP9FmQHvyKTJsqUxCPEueBxBA=; b=PyktA73T0EpdMP25nHKIC6+pYR ePo7FQpi3nT0OD4EhVD1vH7lAqqcsJZJJG36MSe5JAI4UTP3RibTfOsqkyq0qL8/ oVF2di/eCNH2HkQEp6dFXTODuHprDjFmg1ORnZOFjZyIVU83XwO3CkK8Qn40BW9d 2W2oY56GUXWSmWzIw= Received: from localhost.localdomain (unknown [10.7.98.243]) by front02 (Coremail) with SMTP id 54FpogAnLDgqL2JkVboyFA--.10053S2; Mon, 15 May 2023 21:10:06 +0800 (CST) From: Ruihan Li To: linux-mm@kvack.org, linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Pasha Tatashin , David Hildenbrand , Matthew Wilcox , Andrew Morton , Christoph Hellwig , Alan Stern , Greg Kroah-Hartman , Ruihan Li Subject: [PATCH v2 0/4] Fix type confusion in page_table_check Date: Mon, 15 May 2023 21:09:54 +0800 Message-Id: <20230515130958.32471-1-lrh2000@pku.edu.cn> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: 54FpogAnLDgqL2JkVboyFA--.10053S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw1fJw4ktrW7Jw4ftry5urg_yoW8Cw43pF 1UCw13XFs5G3s3Jw1SkanY9a4ruF4rGay7A34xK345u3s5A34xCFn3Wr13Za4kArWUG34Y qF42gryUKw18J37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBI1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2 z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24V AvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xf McIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7 v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF 7I0E8cxan2IY04v7MxkIecxEwVCm-wCF04k20xvY0x0EwIxGrwCF04k20xvE74AGY7Cv6c x26w4UJr1UMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2Iq xVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42 IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY 6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aV CY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbHa0DUUUUU== X-CM-SenderInfo: yssqiiarrvmko6sn3hxhgxhubq/1tbiAgEMBVPy7743xAABsI 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 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/ Changes since v1: * Fix inconsistent coding styles. (Alan Stern) * Relax !DEVMEM requirements to EXCLUSIVE_SYSTEM_RAM, which is equivalent to !DEVMEM || STRICT_DEVMEM. (David Hildenbrand) * A few random tweaks in commit messages and code comments, none of them major. Link to v1: https://lore.kernel.org/lkml/20230510085527.57953-1-lrh2000@pku.edu.cn/T/ Cc: Matthew Wilcox Cc: David Hildenbrand Cc: Pasha Tatashin Cc: Andrew Morton Cc: Alan Stern 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 EXCLUSIVE_SYSTEM_RAM 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 | 20 +++++++++---- 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, 91 insertions(+), 7 deletions(-) -- 2.40.1