Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1504451ybk; Thu, 21 May 2020 08:25:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw91fFmQwcjfnaytPbAEtoAAwIESPuoEtW5D+ZJNDlBvkzKXvJMyKJ1QvAu75BUiTDBqbF1 X-Received: by 2002:a17:906:4009:: with SMTP id v9mr3876245ejj.63.1590074721302; Thu, 21 May 2020 08:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590074721; cv=none; d=google.com; s=arc-20160816; b=bMk52Awu1gd5ZdiOSYh32jaMthY1R8Xe8ezl1UfjAFy+QLhk+vnGX/IqR4/EaFUP4Y uhnFsY1cSXkMMms/hE1qoFNFODKshrQsmzvf9/pt10L3lHPSpwcVAWgyjazF1wEwJvUe 1Kkt8jfxkaKCtp1JdA4SFtXLMqi8vY22ni25sd+Pib1GdYJdRX1jhZtiE0K0yBFl2xLR 4otwxRblkL/GWESpBDgdiYb0rC3/Cp7LuszhaafUrYitd3rZyT1fhLIAKeHlP+o0IEoM QrqIYL1rrWiHXx/ndbNXVgkStHsVjHgR0WmrfAhoorYltvYYDt6UMFMAlPx3vBw15ftU 2Xdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=DBV13RGMAxubtfZ9USCXPl2yvAQJBdbdiRvyHmMlV98=; b=B2TuQIxN/UUtxyK8sSqzagFHOCp+OfGs9546UCPWWbLFG0eURirbxSgClJ+L+A4is1 jbrPZnma8yWtSQ3pTlvRLEhQ9FGsl8nrb+Fw9TskmtjQxcKMzdxOcKDbtQe8eAd4FxjM JMKgNntEPdHtBACQczPrDaHb8fAFM5EyNPP/ZEWF6XxWsrjO9uOieeStgL8FKfv+Eflv z5tJb19QqgCb49owiWubrg+dw/Z1VBFs9aYp5XVVjgzQa4has9z1McMhakpsCZORicR8 H8bsXXgmEg++wvXa1iJoagVqHmwxArTeO8xBWn2vtovfzyuD1ypP0afjc18RJInhF6Ka Nskg== ARC-Authentication-Results: i=1; mx.google.com; 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 y17si3600877ejq.430.2020.05.21.08.24.58; Thu, 21 May 2020 08:25:21 -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; 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 S1730049AbgEUPXU (ORCPT + 99 others); Thu, 21 May 2020 11:23:20 -0400 Received: from foss.arm.com ([217.140.110.172]:48900 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730018AbgEUPXQ (ORCPT ); Thu, 21 May 2020 11:23:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0546BD6E; Thu, 21 May 2020 08:23:16 -0700 (PDT) Received: from e112269-lin.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 64EE13F305; Thu, 21 May 2020 08:23:14 -0700 (PDT) From: Steven Price To: Andrew Morton , Andy Lutomirski , Borislav Petkov , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , x86@kernel.org, Jan Beulich Cc: Steven Price , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 0/2] Fix W+X debug feature on x86 Date: Thu, 21 May 2020 16:23:06 +0100 Message-Id: <20200521152308.33096-1-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jan alert me[1] that the W+X detection debug feature was broken in x86 by my change[2] to switch x86 to use the generic ptdump infrastructure. Fundamentally the approach of trying to move the calculation of effective permissions into note_page() was broken because note_page() is only called for 'leaf' entries and the effective permissions are passed down via the internal nodes of the page tree. The solution I've taken here is to create a new (optional) callback which is called for all nodes of the page tree and therefore can calculate the effective permissions. Secondly on some configurations (32 bit with PAE) "unsigned long" is not large enough to store the table entries. The fix here is simple - let's just use a u64. I'd welcome testing (and other comments), especially if you have a configuration which previously triggered W+X warnings as I don't have such a setup. [1] https://lore.kernel.org/lkml/d573dc7e-e742-84de-473d-f971142fa319@suse.com/ [2] 2ae27137b2db ("x86: mm: convert dump_pagetables to use walk_page_range") Steven Price (2): x86: mm: ptdump: Calculate effective permissions correctly mm: ptdump: Expand type of 'val' in note_page() arch/arm64/mm/dump.c | 2 +- arch/x86/mm/dump_pagetables.c | 33 ++++++++++++++++++++------------- include/linux/ptdump.h | 3 ++- mm/ptdump.c | 17 ++++++++++++++++- 4 files changed, 39 insertions(+), 16 deletions(-) -- 2.20.1