From mboxrd@z Thu Jan 1 00:00:00 1970 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 1D879C433EF for ; Tue, 18 Jan 2022 18:56:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 881DF6B0071; Tue, 18 Jan 2022 13:56:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 809766B0073; Tue, 18 Jan 2022 13:56:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AA376B0074; Tue, 18 Jan 2022 13:56:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 565766B0071 for ; Tue, 18 Jan 2022 13:56:27 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 103AD181CBDBC for ; Tue, 18 Jan 2022 18:56:27 +0000 (UTC) X-FDA: 79044313614.26.366BD07 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 21C881C0006 for ; Tue, 18 Jan 2022 18:56:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=buLSziE+PLhgNnjtRVbSu//iVCKOoSKF7pWZHUatP3A=; b=edvtn1ru0VhuMFSJ5AkoESmZ4I icHI+AujsNL5PHO3zyc/Dy6kT4Kh1qqcusq8p6FDO0dvuouWhUvLwG2TGMQmYhsjXlnLRvslVx8N8 UmxlKDx2g/pj8IeLrS4x2SGRfuc1+CmTaPR2PUtUcZ7EBc8Qwtdv9z075tCqN22kYuuj5jSQED+MN sfl55iwLHl5t5ekTbSyEb+VDZ4rWTi5rfyd3PU7x2DpMVBIMHQiNMUr4rmRs93tlrXuei9H7eZSfF /VPjcEoy5zTa26AmHzANeai/0536NUFULdHhzZCRXpOcGJnpIXtRBUXNrQ66q9SZtxH1R2Vvk2yeh uVGR9z3w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9teO-009T6U-5l; Tue, 18 Jan 2022 18:56:12 +0000 Date: Tue, 18 Jan 2022 18:56:12 +0000 From: Matthew Wilcox To: Yury Norov Cc: Catalin Marinas , Will Deacon , Andrew Morton , Nicholas Piggin , Ding Tianhong , Anshuman Khandual , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH] arm64: don't vmap() invalid page Message-ID: References: <20220118185354.464517-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220118185354.464517-1-yury.norov@gmail.com> X-Rspamd-Queue-Id: 21C881C0006 X-Stat-Signature: 1jen89j6afmz948tajerjzkgj1yryuf8 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=edvtn1ru; spf=none (imf21.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: rspam07 X-HE-Tag: 1642532186-932070 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: On Tue, Jan 18, 2022 at 10:53:54AM -0800, Yury Norov wrote: > vmap() takes struct page *pages as one of arguments, and user may provide > an invalid pointer, which would lead to DABT at address translation later. > Currently, kernel checks the pages against NULL. In my case, however, the > address was not NULL, and was big enough so that the hardware generated > Address Size Abort. > > Interestingly, this abort happens even if copy_from_kernel_nofault() is used, > which is quite inconvenient for debugging purposes. > > This patch adds an arch_vmap_page_valid() helper into vmap() path, so that > architectures may add arch-specific checks of the pointer passed into vmap. > > For arm64, if the page passed to vmap() corresponds to a physical address > greater than maximum possible value as described in TCR_EL1.IPS register, the > following table walk would generate Address Size Abort. Instead of creating > the invalid mapping, kernel will return ERANGE in such situation. This seems like a very elaborate way of spelling: pfn_valid(page_to_pfn(page)); which doesn't require any architecture hook. No?