Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1191203pxb; Fri, 21 Jan 2022 11:54:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/PgRe+2BgJsBS5J8NbAPqzKV4+XCaVub51fUPkUQfaDigeT92Q22tistnXeaHz9J4Lq4+ X-Received: by 2002:a17:902:b944:b0:14a:b045:4d00 with SMTP id h4-20020a170902b94400b0014ab0454d00mr5149980pls.52.1642794854991; Fri, 21 Jan 2022 11:54:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642794854; cv=none; d=google.com; s=arc-20160816; b=c3AYLhCtjNSNh2AnHs3jWuzHTTFHUC4CpJ+jfLUk0GiZDacknqNqF8RJhgeZgmJjcd pEliByRofiZ7Ti7b+svtGQnX5UX1/UJaa59Jaeuku5d6MJqYpP3+L9uBBfqxgTztOyQx 0E3/GN3i/ex2lbilzBCOg3OW4CIN7U9WFwOOQgajQ3L0Z/tjngMZY+H5w/Kc5+aaFYSu /xE2NLuT98Doeg1WKx7F6AGJaWRJqBj0GTnrGrRRmlw160p4klDeq8HYFfFrEloDo0ZF PZGa5r4uo1AYJ1KsAVDkT1FwhxHxwQm7nkl9eZzNgZPM/p432FOIms/fvUTM2r36qeMQ V3uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wl35Nv5bzMCc708L4TqlyxLqxeH3mVDxX3k5zPuEGYo=; b=MdFzkVND2sKYNFbVGfNZauxjHzo0YKr/iwNJdogYfueAraJIagc99Z4xlvs+buXzGJ VN45MCoM23PdkJbaAzXQjfOW4QdQ3va1/8yLxFX48zrB5OU2Yg/dQBDdPrihy+zqge8S FhcmQL0B1N8TMUZBq8//lqkmIcwIq85ubKq0D+jtvBIram315iiNEidKVxZdhWlBq+j5 fw4rdvFYKYrfLIaGg3HP561P70K4SxaJG18QO9ZEvAlL81uA+w5uLD+ipEV3iZzKNF5C s6j+bmuCc8kUTzrmiDEFdUUfFQxOCsamUU/vNdWOyPnidmeFOZktFl8BBwyezkuymdlD omTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=e6nKWnC2; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lw16si14873991pjb.158.2022.01.21.11.54.01; Fri, 21 Jan 2022 11:54:14 -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=pass header.i=@infradead.org header.s=casper.20170209 header.b=e6nKWnC2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349547AbiASSBn (ORCPT + 99 others); Wed, 19 Jan 2022 13:01:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234188AbiASSBm (ORCPT ); Wed, 19 Jan 2022 13:01:42 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22D7AC061574 for ; Wed, 19 Jan 2022 10:01:42 -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=wl35Nv5bzMCc708L4TqlyxLqxeH3mVDxX3k5zPuEGYo=; b=e6nKWnC2p+Tf/OuPB41XZewJTw 9aR5M2y6V/hfTahSIhFlgmKQoZ3OddEQoQb9TKA0jXQ2gbJRF6D0r6+TfbLm/heQJSprsV/QYpqcY qq11o1p/4VBTmIwr4vC84NqqRk0geKSmNkyOUY69cPTWm88tcFDEhTdqyUm7MD1Lbct50fNlKC99a BsyYPEPzDplXfd6VxNXD1dTJDfwfytPkKD8GZO/CVy0HjvUTo6ESV0VgcPXaG/+fAuvU5U+FtEZze H0KgRLdO8+qm8+U5XG8DSeVKCdBYV9XUUZv9SK820h3R+8x+V0sT9bzgLLNLmFZSPNdd5Lmkzn0+L h7HcSL4g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAFGu-00BeGf-9X; Wed, 19 Jan 2022 18:01:24 +0000 Date: Wed, 19 Jan 2022 18:01:24 +0000 From: Matthew Wilcox To: "Russell King (Oracle)" 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 19, 2022 at 05:54:15PM +0000, Russell King (Oracle) wrote: > 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). This function is passed an array of pages. We have no way of doing what you propose.