From patchwork Mon Dec 13 14:27:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12674037 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 A0F5CC433EF for ; Mon, 13 Dec 2021 14:28:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F0AD6B0075; Mon, 13 Dec 2021 09:27:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 49FFE6B0078; Mon, 13 Dec 2021 09:27:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38F596B007B; Mon, 13 Dec 2021 09:27:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id 26A296B0075 for ; Mon, 13 Dec 2021 09:27:20 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DC416181AEF0B for ; Mon, 13 Dec 2021 14:27:09 +0000 (UTC) X-FDA: 78912998178.16.9ED1B19 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 822BD40011 for ; Mon, 13 Dec 2021 14:27:09 +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=zV0YtvdfLCJEMQDqceavC8GyCVu0H6FprTtis1wh+J0=; b=etQyLPPMorbbhW6PS/Oyh0Gr5n maDVOy2meTffMCuCx5lSxzTA3k4HBoHFKZb7nievj9k9o8652Yda2yT5tZqeiw90fYW+AeUmrOjZn S7AGAZuBkL1SVDf/X9GIkZQxlskJorTuBzNcybVLApx/LfjCL4SDlDArupfSPCIXYLRSXWoom+uvu 8cJ/TSJQszrkjalJ/QNq9GZD9HHtyWBXpuImNObjn3/Lu01nc98hAMp6jf+JuVH+L/iRzOqO9MWl/ 6RqciN1E1fYIsUIbRRhUZET0OvkeI8vv0nq40GkKh7wsuCUniYberRoWrljwSLC1pSmKLTGNQd+wK hCPqzc3w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwmID-00Crlr-3n; Mon, 13 Dec 2021 14:27:05 +0000 From: "Matthew Wilcox (Oracle)" To: Kees Cook Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Thomas Gleixner , linux-hardening@vger.kernel.org Subject: [PATCH v3 0/3] Assorted improvements to usercopy Date: Mon, 13 Dec 2021 14:27:00 +0000 Message-Id: <20211213142703.3066590-1-willy@infradead.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Stat-Signature: jqwg45uhtqeh5ha3a9zfkz4kbrfohinf Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=etQyLPPM; spf=none (imf04.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-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 822BD40011 X-HE-Tag: 1639405629-734995 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: We must prohibit page boundary crossing for kmap() addresses. vmap() addresses are limited by the length of the mapping, and compound pages are limited by the size of the page. These should probably all have test cases? 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) (3): mm/usercopy: Check kmap addresses properly mm/usercopy: Detect vmalloc overruns mm/usercopy: Detect compound page overruns arch/x86/include/asm/highmem.h | 1 + include/linux/highmem-internal.h | 10 ++++++++ mm/usercopy.c | 43 +++++++++++++++++++++++--------- 3 files changed, 42 insertions(+), 12 deletions(-) Reviewed-by: William Kucharski