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 X-Spam-Level: X-Spam-Status: No, score=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3308C433F5 for ; Wed, 8 Sep 2021 11:22:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 819EA61078 for ; Wed, 8 Sep 2021 11:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351459AbhIHLXv (ORCPT ); Wed, 8 Sep 2021 07:23:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:60526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232430AbhIHLXt (ORCPT ); Wed, 8 Sep 2021 07:23:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7F82861078; Wed, 8 Sep 2021 11:22:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631100161; bh=ALxiOwLgszVWrVBZDyapBhC1fA/x/vzP431jfN69HAc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jsf2Mw/GVuU9UpcmP2PG0O/Rb4JUi0D7Fovo2UU666jqECJkmEdX9z5av8kdNFKxV thg6JhYxJv8cyhAhdDa2ni3dZ8emj1aT75E6yIF258hGoXVEDb6ipwx/O7QRcbDRwh bn8QspmdbJORahKy4eqxZz43QQHxjBHb2TK24Hytbx6FayPLfKZv57v8I/93lYoXmV mf2Iz1Fc0T5vU//gCwDfaFIlT93OPcQ9Y/EwmLUP4pI6Q3TuCYxYo5tfoP5rLSsbBA cBHY5yrXtZhxb+Npu/Em6Y4P3tf/8y2prV1qIIAdqxFihUjAtsUq/UU2PmAIPo3BeV sj3f0PBq4RCIg== Date: Wed, 8 Sep 2021 14:22:31 +0300 From: Mike Rapoport To: Borislav Petkov Cc: Dave Hansen , x86@kernel.org, Andrew Morton , Andy Lutomirski , Dave Hansen , David Hildenbrand , Ingo Molnar , Jiri Olsa , Mike Rapoport , Oscar Salvador , Peter Zijlstra , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] x86/mm: fix kern_addr_valid to cope with existing but not present entries Message-ID: References: <20210819132717.19358-1-rppt@kernel.org> <35f4a263-1001-5ba5-7b6c-3fcc5f93cc30@intel.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, Sep 08, 2021 at 12:52:45PM +0200, Borislav Petkov wrote: > On Wed, Sep 08, 2021 at 12:35:21PM +0200, Borislav Petkov wrote: > > So I did stare at this for a while, trying to make sense of it and David > > Hildenbrand asked for a Fixes: tag in v1 review and from doing a bit of > > git archeology I think it should be: > > > > c40a56a7818c ("x86/mm/init: Remove freed kernel image areas from alias mapping") > > > > because that thing added the clearing of the Present bit for the high > > kernel image mapping of those areas. > > > > Right? Yes, in a sense. As the only user of kern_addr_valid() is kcore and it only uses this check for high kernel mappings, there should be no problem before 4.19. But... > Hmm, but that commit is in v4.19. Mike has added > > Cc: # 4.4+ > > Mike, why 4.4 and newer? kern_addr_valid() wrongly uses pxy_none() rather than pxy_present() because according to 9a14aefc1d28 ("x86: cpa, fix lookup_address") there could be cases when page table entries exist but they are not valid. So a call to kern_addr_valid() for an address in the direct map would oops. I've stopped digging at 9a14aefc1d28 (which is in v2.6.26) and added the oldest stable we still support (4.4). I agree that before 4.19 it's more of a theoretical bug, but you know, things happen... > Hmmm. -- Sincerely yours, Mike.