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=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 5D2ECC4360C for ; Fri, 11 Oct 2019 00:43:48 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E01321920 for ; Fri, 11 Oct 2019 00:43:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="V5SSXiOU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E01321920 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46q8Mk0MXmzDqV2 for ; Fri, 11 Oct 2019 11:43:46 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=chromium.org (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=keescook@chromium.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="V5SSXiOU"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46q7Xw17XWzDqRx for ; Fri, 11 Oct 2019 11:06:39 +1100 (AEDT) Received: by mail-pf1-x443.google.com with SMTP id q7so4935295pfh.8 for ; Thu, 10 Oct 2019 17:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZBHIZP91az7zFwublbVFIxiUPIvhqcpifj2fGv96nM4=; b=V5SSXiOU/2LqW+YWMWv2g8oE+O+8OqaVciMsltfBT6XAT+UmV5TNibrJhEtO410tXb /OnY7p2PJHhLZDVx/eoiV5CS19ovJ8wYT+GUzFT433OArvUWowNhqhNxhPEcl3xsRkLc lb2h6DldDdTdhb4T8VOEQWN9DqKeDub1PenXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZBHIZP91az7zFwublbVFIxiUPIvhqcpifj2fGv96nM4=; b=Od5DKUTaerqgQnfQaDhrxm/Qp/IqgR2yfnlFmaSNvBOKvAZk1TeGqgED0UihLRjRGW N1+9uzWW4VfzuQao1ilFX3kOlggbkG+8jha/m9AfvEEVN869IVbzmGzwOuoX7e/IR6tG zfQLnIHuK9XtbtkpVxj1yoY0YCzPm9AtJN8s6mMyn4GAbBD9AduR+MxVxs7XLPT1uAqY 9FOaQW03PypogqeQjTpMQQ6xQ9ZykyJ4ERyL53DdoDSyHA+o21SZMDOx5fPhLK5gfNGD bNPoV9sTCNYH+kpLbFcC7xReYOo6Odju7Y1QPtxNMoq2DsALQFGKdoeQQJ7Hefrv1+XF bLrQ== X-Gm-Message-State: APjAAAVeaDTRC5zgumimcgQ/EKPJrSaionAAiftFqWrt/2aRaSAxIX71 4+PpftP+rJyRwK+YVd5v3JOkVw== X-Google-Smtp-Source: APXvYqxIURRErEoWhZaXwUViGgbdz47KTCDz+s6x66JTdawkgAKVzwgCcLp2sAcohHOnlA3CSEfhcA== X-Received: by 2002:aa7:9157:: with SMTP id 23mr13458255pfi.73.1570752397032; Thu, 10 Oct 2019 17:06:37 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n15sm5864975pjt.13.2019.10.10.17.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 17:06:35 -0700 (PDT) From: Kees Cook To: Borislav Petkov Subject: [PATCH v2 28/29] x86/mm: Report actual image regions in /proc/iomem Date: Thu, 10 Oct 2019 17:06:08 -0700 Message-Id: <20191011000609.29728-29-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191011000609.29728-1-keescook@chromium.org> References: <20191011000609.29728-1-keescook@chromium.org> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Michal Simek , x86@kernel.org, linux-ia64@vger.kernel.org, Kees Cook , Arnd Bergmann , linux-xtensa@linux-xtensa.org, Dave Hansen , Heiko Carstens , linuxppc-dev@lists.ozlabs.org, Yoshinori Sato , linux-parisc@vger.kernel.org, Andy Lutomirski , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, Rick Edgecombe , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" The resource reservations in /proc/iomem made for the kernel image did not reflect the gaps between text, rodata, and data. Add the "rodata" resource and update the start/end calculations to match the respective calls to free_kernel_image_pages(). Before (booted with "nokaslr" for easier comparison): 00100000-bffd9fff : System RAM 01000000-01e011d0 : Kernel code 01e011d1-025619bf : Kernel data 02a95000-035fffff : Kernel bss After: 00100000-bffd9fff : System RAM 01000000-01e011d0 : Kernel code 02000000-023d4fff : Kernel rodata 02400000-025619ff : Kernel data 02a95000-035fffff : Kernel bss Signed-off-by: Kees Cook --- arch/x86/kernel/setup.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 77ea96b794bd..591e885a852e 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -143,6 +143,13 @@ struct boot_params boot_params; /* * Machine setup.. */ +static struct resource rodata_resource = { + .name = "Kernel rodata", + .start = 0, + .end = 0, + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM +}; + static struct resource data_resource = { .name = "Kernel data", .start = 0, @@ -951,7 +958,9 @@ void __init setup_arch(char **cmdline_p) code_resource.start = __pa_symbol(_text); code_resource.end = __pa_symbol(_etext)-1; - data_resource.start = __pa_symbol(_etext); + rodata_resource.start = __pa_symbol(__start_rodata); + rodata_resource.end = __pa_symbol(__end_rodata)-1; + data_resource.start = __pa_symbol(_sdata); data_resource.end = __pa_symbol(_edata)-1; bss_resource.start = __pa_symbol(__bss_start); bss_resource.end = __pa_symbol(__bss_stop)-1; @@ -1040,6 +1049,7 @@ void __init setup_arch(char **cmdline_p) /* after parse_early_param, so could debug it */ insert_resource(&iomem_resource, &code_resource); + insert_resource(&iomem_resource, &rodata_resource); insert_resource(&iomem_resource, &data_resource); insert_resource(&iomem_resource, &bss_resource); -- 2.17.1