Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp733103rwi; Thu, 20 Oct 2022 04:45:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yk+RMKG15z/EBhh6wDHAo1Z/m6kl9UnCzcOt2EU1MqMJps1qDAAha2jx5zc3JrBr//vFe X-Received: by 2002:a05:6402:5114:b0:45d:b850:a4e2 with SMTP id m20-20020a056402511400b0045db850a4e2mr11556821edd.316.1666266305446; Thu, 20 Oct 2022 04:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666266305; cv=none; d=google.com; s=arc-20160816; b=a8v3YOtjOR6JX9ibY4t4d6mQd5h0YO9Ny1VNOgG32vgHbW1aYVVBYcksHoaFpeFOVj Cr/tKVRln4C/2kkTu6DOLMFsXkPPNF1M185Q0mzBv/iBTakRton+GnArvV7LHPQJNFs+ JVBUMikInpNWQz7Ix5We9yamOqlPxfRnx1kE5gw4NEnQwEfXlPmLIS9SZTAF/43Qc2Lg F7xaLHMLDUmJ/yJfxViHryEdMWR8gwCavMXmGonrT8FYrscr3QbfV0C6jB7kAM/HcI49 WsBvXeCiDVhKqSGn47pV3gYQxxcZ9iCl9gZ1J8yxkNMPWbvouArBMh2xufdSe/fZxciM 3Z4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version :dkim-signature:dkim-filter; bh=Vzl/zXUMMGbEKj/S8AF15wH6J143avkWXBRh1JpAXNM=; b=klEYBKlCsdf6VnuIpkUNSM+CODG6RCquce+VDEhFyVNtpJLBALJ8377/zpVorH++91 OiuG63jXdfUmy8fVM36UEb6q6gaaqzr9y1eVCMPNTqOHNMUhN/5L9f7rCSzEKxs1g5ML FW4qorO/33yGtqDpjTcVvX3zems8rT1eCT+eZYnDtrOZH0n6dTaUfTedUHBacKN75avi 47qBIelpBwa9HOWNsuYXBBhPV9+WJm/S/pA4MwOQP2yPC7ORb1vkkLmT/WZB8HBPF88w zJabRnFDY9rhF4fYN0NwLJ4MjghfIsvRW8f7UDGEXjSNQOSj+n2v6CEppyTbEukwLoou xDzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b="ttG/TNbP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11-20020aa7de8b000000b004593fb0c125si14194590edv.103.2022.10.20.04.44.37; Thu, 20 Oct 2022 04:45:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b="ttG/TNbP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230521AbiJTLNI (ORCPT + 99 others); Thu, 20 Oct 2022 07:13:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbiJTLNH (ORCPT ); Thu, 20 Oct 2022 07:13:07 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64A141E0451; Thu, 20 Oct 2022 04:13:06 -0700 (PDT) Received: from mail.ispras.ru (unknown [83.149.199.84]) by mail.ispras.ru (Postfix) with ESMTPSA id B1913419E9C7; Thu, 20 Oct 2022 11:13:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru B1913419E9C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1666264384; bh=Vzl/zXUMMGbEKj/S8AF15wH6J143avkWXBRh1JpAXNM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ttG/TNbPNg+eoZL3NzW76ndIeZcOn0XU6KbIdikucrd+nJs2ItqOTPEQ+C7uydvO7 lUCJ46wuMEcWoa0K3Re2N58amW3tSiXT8gRCkybit0LLwmeFnQlPT+mW1KEIzKFJvQ XoIuY50aJ/WBzrstbJL+FczBaPCtHCowbklADM90= MIME-Version: 1.0 Date: Thu, 20 Oct 2022 14:13:04 +0300 From: Evgeniy Baskov To: Ard Biesheuvel Cc: Borislav Petkov , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , lvc-project@linuxtesting.org, x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 01/16] x86/boot: Align vmlinuz sections on page size In-Reply-To: References: <27a078f43742063cc30e706b196fb5fff5d5c37e.1662459668.git.baskov@ispras.ru> User-Agent: Roundcube Webmail/1.4.4 Message-ID: X-Sender: baskov@ispras.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-10-19 10:01, Ard Biesheuvel wrote: > On Tue, 6 Sept 2022 at 12:41, Evgeniy Baskov wrote: >> >> To protect sections on page table level each section >> needs to be aligned on page size (4KB). >> >> Set sections alignment in linker script. >> >> Signed-off-by: Evgeniy Baskov >> --- >> arch/x86/boot/compressed/vmlinux.lds.S | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/arch/x86/boot/compressed/vmlinux.lds.S >> b/arch/x86/boot/compressed/vmlinux.lds.S >> index 112b2375d021..6be90f1a1198 100644 >> --- a/arch/x86/boot/compressed/vmlinux.lds.S >> +++ b/arch/x86/boot/compressed/vmlinux.lds.S >> @@ -27,21 +27,27 @@ SECTIONS >> HEAD_TEXT >> _ehead = . ; >> } >> + . = ALIGN(PAGE_SIZE); >> .rodata..compressed : { >> + _compressed = .; > > Why are you adding these? It is used for address compressed kernel blob during memory protection setup. Although it can be addressed via different symbols, I though that addressing sections data in a common way (through linker generated symbols) would be better. I can remove or mention the change in commit message (for now I will do the latter). > >> *(.rodata..compressed) >> + _ecompressed = .; >> } >> + . = ALIGN(PAGE_SIZE); > > On other EFI architectures, we only distinguish between R-X and RW- > regions, and alignment between .rodata and .text is unnecessary. Do we > really need to deviate from that here? I though that leaving a huge compressed kernel blob executable is undesirable, so I decided to split it out. I can make it either RW- or R-X if it would be more acceptable. > > >> .text : { >> _text = .; /* Text */ >> *(.text) >> *(.text.*) >> _etext = . ; >> } >> + . = ALIGN(PAGE_SIZE); >> .rodata : { >> _rodata = . ; >> *(.rodata) /* read-only data */ >> *(.rodata.*) >> _erodata = . ; >> } >> + . = ALIGN(PAGE_SIZE); >> .data : { >> _data = . ; >> *(.data) >> -- >> 2.35.1 >>