Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1191784pxb; Fri, 21 Jan 2022 11:55:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvqRreG07GVj7JpM6qlKRBReg+V6qL/+jAtoZUnWQNhXa4ek+bw7yj15Qkg12/6bZ4p05h X-Received: by 2002:a05:6a00:1d26:b0:4c0:2388:73c6 with SMTP id a38-20020a056a001d2600b004c0238873c6mr4969917pfx.69.1642794902071; Fri, 21 Jan 2022 11:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642794902; cv=none; d=google.com; s=arc-20160816; b=osKV5i6WtxSywh6Vv4BcEZb6h3sj0mSYXjWw/4aF8JTerkRLmj4ve96YTTataS9kmQ KtgkJmchrPd/Jxx0janZ7fxtpHh5QzAfjiTyJ3GfSUsuuM8z0n+bkZyYhKxqDtakqZ7N gtWx3klvzyZdaedplmyfO9D4nkAO/7v0swz/MXJ/ijen2o4doY//SZ4Ism+3qyZ3+aBd Isn1LZoA+5Da2H1QwBYHxt/crwpJCqGDvGbhQ7ofpf7vU++1yzGrNprG/fk8XntpNCh5 TGIcjt1yJYyFK0cj72IiJ9SuLrxtFN2l2WyHYest0GYAUA0S7S3EbM+Gd5Pf+aVmL0kV DOEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=unKRq3+Qh51MnwlGbQRTSZfvWAAVcrjJNDrQsffLRoE=; b=M1yCHfK/pyRTZbWGiAAX6yZqAskRcPFcydLeGRWOkio+Hj3OiLIjeNIcpIuufGkl2D 1nSW5ypwFWN4Dv9WNUauInbLexMTSbnJXoeKWHCL6F+jtJGqTz+JgB15kIUhcfZmE6uC uFvv7MqkcINHgBdR6c0iIpXULdbIweFwPzjP+YMCHyeVjBUckNjW6e6KQge3uoST+WC2 212Lk6j8wm0G5TPl/w+3lGk1arkjNFzuafJ7fnFBbmteBQtvPSerZmauLcvKOqeR7D/X 9CZAEDtwobttAE6Lwi8X2By250mrg9fwgwLdsVnRgWTrqsw82wtuyuECwLUcAV1Brkgv 85ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=lNv2TQPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n14si2102988plf.496.2022.01.21.11.54.49; Fri, 21 Jan 2022 11:55:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=lNv2TQPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356552AbiASRyp (ORCPT + 99 others); Wed, 19 Jan 2022 12:54:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344434AbiASRyp (ORCPT ); Wed, 19 Jan 2022 12:54:45 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E843C061574 for ; Wed, 19 Jan 2022 09:54:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=unKRq3+Qh51MnwlGbQRTSZfvWAAVcrjJNDrQsffLRoE=; b=lNv2TQPpQwY5mfxhjvKLg2EDRL AMKBR9MGe26Y3fMyV7upvAJT43SQwAkrYb+v+weXlBuwJ3Gy3NYyhiA9Esr3pWTbrLwIvCe/qdhiO 58Rw0c+QHTeTnrVq+bx1Ru2KW2Ex2tjmGPBZtmJpE/NUzjxYNaF6P+HpJ9/ZmNDn332pawnjX7op4 /S220jgMQFz4Latm8e09vHZjfT15DP3gxNlRgtRu+kBm4LOM9t0C/2MiwYAZh1JIVAPycdUuRWmpv NkRkDkNPlLqD/XZdQb+tw4Js0Tzz6cbJguLjszXZ84kKZCfATnIRKkoE5mZ+ihZkDmXKdymGZ2YI+ ZPxjWimg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:56780) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nAFA4-000502-HE; Wed, 19 Jan 2022 17:54:20 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nAF9z-0005Rq-9b; Wed, 19 Jan 2022 17:54:15 +0000 Date: Wed, 19 Jan 2022 17:54:15 +0000 From: "Russell King (Oracle)" To: Matthew Wilcox Cc: Robin Murphy , Yury Norov , Catalin Marinas , Will Deacon , Andrew Morton , Nicholas Piggin , Ding Tianhong , Anshuman Khandual , Alexey Klimov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] vmap(): don't allow invalid pages Message-ID: References: <20220118235244.540103-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 19, 2022 at 04:27:32PM +0000, Matthew Wilcox wrote: > On Wed, Jan 19, 2022 at 01:28:14PM +0000, Robin Murphy wrote: > > > + if (WARN_ON(!pfn_valid(page_to_pfn(page)))) > > > > Is it page_to_pfn() guaranteed to work without blowing up if page is invalid > > in the first place? Looking at the CONFIG_SPARSEMEM case I'm not sure that's > > true... > > Even if it does blow up, at least it's blowing up here where someone > can start to debug it, rather than blowing up on first access, where > we no longer have the invlid struct page pointer. > > I don't think we have a 'page_valid' function which will tell us whether > a random pointer is actually a struct page or not. Isn't it supposed to be: if (!pfn_valid(pfn)) { handle invalid pfn; } page = pfn_to_page(pfn); Anything else - even trying to convert an invalid page back to a pfn, could well be unreliable (sparsemem or discontigmem). -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!