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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 CA419C433E0 for ; Tue, 16 Jun 2020 07:23:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B104F20734 for ; Tue, 16 Jun 2020 07:23:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726665AbgFPHXW (ORCPT ); Tue, 16 Jun 2020 03:23:22 -0400 Received: from verein.lst.de ([213.95.11.211]:36722 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgFPHXW (ORCPT ); Tue, 16 Jun 2020 03:23:22 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 0F9A368AFE; Tue, 16 Jun 2020 09:23:19 +0200 (CEST) Date: Tue, 16 Jun 2020 09:23:18 +0200 From: Christoph Hellwig To: Dexuan Cui Cc: vkuznets , Christoph Hellwig , Stephen Hemminger , Andy Lutomirski , Peter Zijlstra , Andy Lutomirski , Michael Kelley , Ju-Hyoung Lee , "x86@kernel.org" , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , KY Srinivasan , Tom Lendacky Subject: Re: hv_hypercall_pg page permissios Message-ID: <20200616072318.GA17600@lst.de> References: <20200407073830.GA29279@lst.de> <87y2ooiv5k.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 15, 2020 at 07:49:41PM +0000, Dexuan Cui wrote: > I did this experiment: > 1. export vmalloc_exec and ptdump_walk_pgd_level_checkwx. > 2. write a test module that calls them. > 3. It turns out that every call of vmalloc_exec() triggers such a warning. > > vmalloc_exec() uses PAGE_KERNEL_EXEC, which is defined as > (__PP|__RW| 0|___A| 0|___D| 0|___G) > > It looks the logic in note_page() is: for_each_RW_page, if the NX bit is unset, > then report the page as an insecure W+X mapping. IMO this explains the > warning? It does. But it also means every other user of PAGE_KERNEL_EXEC should trigger this, of which there are a few (kexec, tboot, hibernate, early xen pv mapping, early SEV identity mapping) We really shouldn't create mappings like this by default. Either we need to flip PAGE_KERNEL_EXEC itself based on the needs of the above users, or add another define to overload vmalloc_exec as there is no other user of that for x86.