Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp2837534pjo; Mon, 16 Mar 2020 05:39:00 -0700 (PDT) X-Google-Smtp-Source: ADFU+vut6sxivETj+4OGt7jDoZGEasqVgqwzM8IoGeDdeT4vukbv6xOhwqeEClBzeztdVV0aftey X-Received: by 2002:a05:6808:abb:: with SMTP id r27mr17518872oij.92.1584362340591; Mon, 16 Mar 2020 05:39:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584362340; cv=none; d=google.com; s=arc-20160816; b=XnufSrfmSGViRuCpe4K2Z9DgwnXMG8YO1ZDqGFYHp9n7a7k9p/3Eg+lGgq+uLlvQsY 0mzWgOdH13nN0dLpSN0P/77hL6MxF0r0+1RiyqpGAF+X8MTvv2ulOmrsVXde0cbPmspS Oix3mIR66YU5NBARQtB7zUOx8XensDxh9zrLqk+bScaTihk4MvROO9hoWjN+MNeS+dVV Lcm0zcjeGn4ZENLSPSLqt2IMA0W2J3T2g4bqh14gkbJW8NKnhYBdjM3/iyZk5WTVNjBa 65keip2seQs4atpCVyJA1SWaFHIl69sSDwt7mww9JrLFrE+si64dg3gWJNQx4n4968ee pajQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=hibOU5R/OOVSCbKxBckJsXxey54bepL2u8F60pyCjN0=; b=TdX97aRg+qxlndxkyLVETYgZGkPgo9IC7E9SiDJFLD/QItt3wNUp/78fqzf3v0V+Z8 Uwau+XXA28llbYiK01/Qx8FL7DEh/IPi8Skzh+F0iaRS5Oc7PtYQKx7DUpzjnuIUCoJF TH4DIOkSTnnpLExNYSrDqhfpEg7bWkQUAfK62sk55ve1lYuJitNPjVRbp7ezv4sp7zva 5ybsLv82isP7MDDXHvwnyhSe4Daq0u3NEOB321RNzlJoXQdTnH9gNt41m9gmfja4XE9E oTACYzIC3lzdbjhqDKagdiFhY5Ly2/9ohShfjxKOsLouzIw5AUPkTqYZIFlfTIJ6Hr0I lHOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=DPXptArc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9si3701122otk.97.2020.03.16.05.38.48; Mon, 16 Mar 2020 05:39:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=DPXptArc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731155AbgCPMgJ (ORCPT + 99 others); Mon, 16 Mar 2020 08:36:09 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:43841 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731103AbgCPMgB (ORCPT ); Mon, 16 Mar 2020 08:36:01 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48gwkz5QqFz9v02k; Mon, 16 Mar 2020 13:35:55 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=DPXptArc; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id H9KWIfoUvdr9; Mon, 16 Mar 2020 13:35:55 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48gwkz4R6bz9v02g; Mon, 16 Mar 2020 13:35:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1584362155; bh=hibOU5R/OOVSCbKxBckJsXxey54bepL2u8F60pyCjN0=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=DPXptArcV0m32C0yXO4COIQT9BfklaYWZm+jL6dYSP1FkCvQDrQaXQblEIB8LA2EU Jn3auOrFL3O4kIcDu5GzIxzs0GZWSA2PTty43sdbc0fz+OGkCQw+56N58KiwllUPC5 01oTzhuQc6fbAL+wVG4zaHI+eWaC41FLtjbVTjOc= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 939408B7D0; Mon, 16 Mar 2020 13:36:00 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id cWfAhbgEwlxF; Mon, 16 Mar 2020 13:36:00 +0100 (CET) Received: from pc16570vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.100]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 76A088B7CB; Mon, 16 Mar 2020 13:36:00 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 6D5FD65595; Mon, 16 Mar 2020 12:36:00 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 15/46] powerpc/32s: Don't warn when mapping RO data ROX. To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 16 Mar 2020 12:36:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mapping RO data as ROX is not an issue since that data cannot be modified to introduce an exploit. PPC64 accepts to have RO data mapped ROX, as a trade off between kernel size and strictness of protection. On PPC32, kernel size is even more critical as amount of memory is usually small. Depending on the number of available IBATs, the last IBATs might overflow the end of text. Only warn if it crosses the end of RO data. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/book3s32/mmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/mm/book3s32/mmu.c b/arch/powerpc/mm/book3s32/mmu.c index 39ba53ca5bb5..a9b2cbc74797 100644 --- a/arch/powerpc/mm/book3s32/mmu.c +++ b/arch/powerpc/mm/book3s32/mmu.c @@ -187,6 +187,7 @@ void mmu_mark_initmem_nx(void) int i; unsigned long base = (unsigned long)_stext - PAGE_OFFSET; unsigned long top = (unsigned long)_etext - PAGE_OFFSET; + unsigned long border = (unsigned long)__init_begin - PAGE_OFFSET; unsigned long size; if (IS_ENABLED(CONFIG_PPC_BOOK3S_601)) @@ -201,9 +202,10 @@ void mmu_mark_initmem_nx(void) size = block_size(base, top); size = max(size, 128UL << 10); if ((top - base) > size) { - if (strict_kernel_rwx_enabled()) - pr_warn("Kernel _etext not properly aligned\n"); size <<= 1; + if (strict_kernel_rwx_enabled() && base + size > border) + pr_warn("Some RW data is getting mapped X. " + "Adjust CONFIG_DATA_SHIFT to avoid that.\n"); } setibat(i++, PAGE_OFFSET + base, base, size, PAGE_KERNEL_TEXT); base += size; -- 2.25.0