Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp464513pxb; Wed, 8 Sep 2021 05:24:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzP0kdWxAeg/I0c3/rcS+Qf0O2iTNMi9RHUHRSh8ozN/qJFdQddYI1UKh1EMC1x344TzsNy X-Received: by 2002:a92:cda4:: with SMTP id g4mr2621560ild.236.1631103875739; Wed, 08 Sep 2021 05:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631103875; cv=none; d=google.com; s=arc-20160816; b=UcubAZih7kr1YOjQ3p4e40lPofVKCczOKsj8f6OTG6AMH/kqS1Wg8rdTgb1wUxA5bZ P64TA3X+kG+eW5AxKB0RsSeB7dKtmZpnzVfjx2Z8ao7C32vCUl+T170+7XCzWlmN2qpe fHsD32ER8yJRAriW8NmyPUdUga6XAgTQa97kvo6m8r9sn6cvxvfnIfANu3M64II3sKXS 83gFKhFmujRobFolnwFd/apFLhQ2qWiHwDI9KPpllHBDRKDAGxfPM+T3oPupJ1XhzGF0 +XnZKnD6Jrf84FPaJOJXVb5EEY0PNmjzfZShvtFVqP8c2lFYJl+tY5AM2lj9XERbKIK6 6L0w== 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=Hvy3Gk1inxNGLpYQmpT3hQKBF1F2CQPBmxc20y87JvQ=; b=pvV6HJW/59HZawfibPEMi9Hca0jozUit3jij+Iig++dq3+4e01EvJ5LG5BTM0MoOWD upOV/AsyC45hKeuPqaeDhDkYaK+4aWSCTkiY/5uPZJa7WT3ttJ1JNFyp6a2R9z3KfZQi ZiFE0yik79uOvgdj8+Wj07tg8izeywU5UMULhGTmsI6y5W7XsNeN5mOZli7SlNn3QxUO HP5L7VR9zuXwK6BQgDXAL2GSmDNfklBW1Jxn7VdUAoQ33zDqvvHPbVEXdcbLfR4ZcPUj R4RztBAHeOyu7KS6mvpeXDYb82HO+RmVDrscNleOv+zHnhdp9DXho5sfLXiIkIozz5Ep 2lnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="jsf2Mw/G"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si2351977ilo.31.2021.09.08.05.24.13; Wed, 08 Sep 2021 05:24:35 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b="jsf2Mw/G"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351455AbhIHLXu (ORCPT + 99 others); Wed, 8 Sep 2021 07:23:50 -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.