From patchwork Mon Jan 10 23:15:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12709265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CD83C433F5 for ; Mon, 10 Jan 2022 23:15:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02AF56B007B; Mon, 10 Jan 2022 18:15:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF46C6B007D; Mon, 10 Jan 2022 18:15:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBCC96B007E; Mon, 10 Jan 2022 18:15:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id CBE006B007B for ; Mon, 10 Jan 2022 18:15:47 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 91A65181DB468 for ; Mon, 10 Jan 2022 23:15:47 +0000 (UTC) X-FDA: 79015936734.15.F9E128F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id 45876100003 for ; Mon, 10 Jan 2022 23:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=gkLyQW+6Ycdwdc+pNLLo7lhLSJHZ64K0RTb7J06MeVI=; b=eUeTG0xNkuY1sWiCq8xs6o+qzL ZknC/MqaeLBJOt/ELt02bb+ICarfDB97zD6FoOsY7CGypcinxzEgGSW142+kmCBzgWPtmIpNb7XME u12tOhe2QWv9YxEt154MjEiv30jO8jsGuW/vbkNmHE+9CbK32TIvOHLfOmTIODMVMlolg3TWI0iHI I9PW6215jJxlpSQ/dr4W8g4C/eiyxdn6ZhZHLmDrJp9agJ5pHvY2b6+7wd3awbK8jndQzsUYH9Cwc 2s/WGytDuXLoIos1HG6E12/IwMFKR+m4Vqc7GsbCCIhLnC/QHRErpc845QqJj2VeFaAuPC8Z9leUd FwAubJZA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n73sy-002nGD-AF; Mon, 10 Jan 2022 23:15:32 +0000 From: "Matthew Wilcox (Oracle)" To: Kees Cook Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-hardening@vger.kernel.org Subject: [PATCH 0/4] Assorted improvements to usercopy Date: Mon, 10 Jan 2022 23:15:26 +0000 Message-Id: <20220110231530.665970-1-willy@infradead.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 45876100003 X-Stat-Signature: z3eyiopyo9f61j49943sch94fjf44fma Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eUeTG0xN; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1641856547-161283 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The HARDENED_USERCOPY_PAGESPAN config option is hard to turn on because much of the kernel uses non-compound high-order page allocations. This patchset extracts the valuable parts of HARDENED_USERCOPY_PAGESPAN and then removes the remainder. v5: - Use get_vm_area_size() instead of ->size directly (Mark Hemment) - Rebase to current Linus (the slab merge changed a lot of code) v4: - Add the fourth patch to remove HARDENED_USERCOPY_PAGESPAN v3: - Remove a now-unused variable v2: - Prevent a NULL pointer dereference when a vmalloc-range pointer doesn't have an associated allocation (me) - Report better offsets than "0" (Kees) Matthew Wilcox (Oracle) (4): mm/usercopy: Check kmap addresses properly mm/usercopy: Detect vmalloc overruns mm/usercopy: Detect large folio overruns usercopy: Remove HARDENED_USERCOPY_PAGESPAN arch/x86/include/asm/highmem.h | 1 + include/linux/highmem-internal.h | 10 ++++ mm/usercopy.c | 97 +++++++++----------------------- security/Kconfig | 13 +---- 4 files changed, 39 insertions(+), 82 deletions(-)