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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CE0AC433F5 for ; Tue, 18 Jan 2022 18:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245390AbiARS4k (ORCPT ); Tue, 18 Jan 2022 13:56:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348466AbiARS4Y (ORCPT ); Tue, 18 Jan 2022 13:56:24 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F013CC06173F for ; Tue, 18 Jan 2022 10:56:23 -0800 (PST) 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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?