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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1149FC433F5 for ; Tue, 18 Jan 2022 18:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tAXEXiU9HNAqjRI7Ve9WSQVWTXO00zO9qt89xY5MDi4=; b=ibwf7+vLQIc8nn aVN2qQrN2nTPDUaOfFAG/K3rHOB+QSB7I3XTTAYhQpSW4NBPNMH/46/eFLldQAqBQPuRhwCQLGr5z mRyCigi0mcV3RtC9exmtzsxe8m1rJkB6O1ZZhfCf+Nf/Q3IlHOszZbp7Uvn5D2xAFKV2idy74KcK+ cz6rn9qsX042m4xuOHMrryjCHaJQLpTZxdJD+EQ0QAt9AATng6bFdezuRy8mZ8W8WmL1i5L4QVANI NB8tM3FITbUxGkNVR4NT5JdMOTAgsJ9JXehSV0l9pL4DS8DpVKQkHxOOtb2lOadD4NtqXgjVGXmkr PnQXht1aBPDNMkVCgjBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9teU-002gy5-Mu; Tue, 18 Jan 2022 18:56:18 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9teT-002gxg-23 for linux-arm-kernel@bombadil.infradead.org; Tue, 18 Jan 2022 18:56:17 +0000 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-Disposition: inline In-Reply-To: <20220118185354.464517-1-yury.norov@gmail.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel