From patchwork Tue Oct 29 21:13:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11218613 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3724014E5 for ; Tue, 29 Oct 2019 21:23:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 1497321734 for ; Tue, 29 Oct 2019 21:23:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Bk8mZOzv"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="M9SLwOql" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1497321734 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rTAlLTCYWXdAuI36vCnTPWrl21c1n5566LhbStnbDJ8=; b=Bk8mZOzvidY9QziF6vfJLu7q18 g8c4XLiYCB8UnO2Ip18sIShp2O9Uweb32f5dHD6nFaiitB/7fKa8b6I0vItQs91ffPRTT9JtopCwk ObKS04ab06BpO17RnGdMj56N61uAlEeBUZ0pM/grpVFs5xheulCcXliZrvcDhP570jY1bDsCxUqFh bg7o2DKsv3mh80O0/uC8ZtYyR6GT2A+b7w9vGEhkOrua/NmGyYZIZvfQQWIj20HzQjB2NpGCciwC+ +MecXE0XP2V5By8rrC/B0tKe57A3CkIv+NUJ5AXnrLtQmIsReYqRvj8+wSd+xJ++vzvNYRPx6AWo2 IuFYxX4A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iPYxU-0005t4-U0; Tue, 29 Oct 2019 21:23:20 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iPYuy-0003re-NW for linux-arm-kernel@lists.infradead.org; Tue, 29 Oct 2019 21:20:47 +0000 Received: by mail-pl1-x644.google.com with SMTP id w8so8319696plq.5 for ; Tue, 29 Oct 2019 14:20:44 -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=M9SLwOqlCa0SlvU6700EwTLQUuzWEag9vc7KatkdsGeJwPHlQA3WRv3Dom23V4MK8s d+jpadskDGheIyph/HLT/ldCh7qJWlBJNP+9zzPq9Crtc+afBTw4Cw4pK4aix9zvmD0d xIF4MEF78TJPndhmgwz2pgwlB8Vu/k8/ZcHto= 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=LX8mglojK5lz/boeuFa4VahnfP/Ktk1KO+xyaYhRbJG8aIzzWXVm9VRaUVuCpTP4yf DkwBqzgEuwN7aq63gYp9QeAQmPQWSFr5LGkdTNHFx3EQHxVLmiJgpGPUrwVoaLVNy2JX jDfCXfZjxWM9lSe2VPynex4bQdvRtonf5ti2+Jmsd3RtB0CwH2wGQ6zLvZLTZHXqhnHZ J8F0MXXezpWpY4+q1h78P0qKlRJ9tkuRLFRMixLZTBY9PJYfphT/NvoA+WqGU69I8mNs u1W2dPb2K8u+bXbBFGp6bC+NS3/rbvJ9DnMHB7dEYUQLuTlwTmxeAemzADyqgHL1hGgB WvWA== X-Gm-Message-State: APjAAAWemGsf9AZxGF3xKkXMRXES1aRre71IHBq5CLfTwcqtWBauGu2V NzgxDxpUolpS5DIFY43qQ64Glg== X-Google-Smtp-Source: APXvYqz+FkHH/yDgWExtFSRjauHPZVacJz4RWr1uXvh1akMds8Xo/d8oORJ64oL3kpz7Ccp5iUDQiw== X-Received: by 2002:a17:902:6b8a:: with SMTP id p10mr815695plk.192.1572384043174; Tue, 29 Oct 2019 14:20:43 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id r10sm132454pgn.68.2019.10.29.14.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 14:20:38 -0700 (PDT) From: Kees Cook To: Borislav Petkov Subject: [PATCH v3 28/29] x86/mm: Report actual image regions in /proc/iomem Date: Tue, 29 Oct 2019 14:13:50 -0700 Message-Id: <20191029211351.13243-29-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029211351.13243-1-keescook@chromium.org> References: <20191029211351.13243-1-keescook@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191029_142045_027380_18FFF642 X-CRM114-Status: GOOD ( 12.99 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:644 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Michal Simek , linux-ia64@vger.kernel.org, Kees Cook , Arnd Bergmann , Michael Ellerman , Dave Hansen , Segher Boessenkool , linuxppc-dev@lists.ozlabs.org, Heiko Carstens , Yoshinori Sato , Andy Lutomirski , linux-alpha@vger.kernel.org, Rick Edgecombe , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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);