lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXFjQemVpHph2K+ysNO44uH3E7mjfc0o+JPV+gzi+mtoZA@mail.gmail.com>
Date:   Wed, 8 Mar 2023 11:47:20 +0100
From:   Ard Biesheuvel <ardb@...nel.org>
To:     Evgeniy Baskov <baskov@...ras.ru>
Cc:     Borislav Petkov <bp@...en8.de>, Andy Lutomirski <luto@...nel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Alexey Khoroshilov <khoroshilov@...ras.ru>,
        Peter Jones <pjones@...hat.com>,
        "Limonciello, Mario" <mario.limonciello@....com>,
        joeyli <jlee@...e.com>, lvc-project@...uxtesting.org,
        x86@...nel.org, linux-efi@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH v4 06/26] x86/boot: Setup memory protection for bzImage code

On Thu, 15 Dec 2022 at 13:38, Evgeniy Baskov <baskov@...ras.ru> wrote:
>
> Use previously added code to use 4KB pages for mapping. Map compressed
> and uncompressed kernel with appropriate memory protection attributes.
> For compressed kernel set them up manually. For uncompressed kernel
> used flags specified in ELF header.
>
> Tested-by: Mario Limonciello <mario.limonciello@....com>
> Tested-by: Peter Jones <pjones@...hat.com>
> Signed-off-by: Evgeniy Baskov <baskov@...ras.ru>
>

This patch breaks the 'nokaslr' command line option (at least with
SeaBIOS) unless I apply the hunk below:


--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -329,7 +329,8 @@ static size_t parse_elf(void *output, unsigned
long output_len,

        handle_relocations(output, output_len, virt_addr);

-       if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE))
+       if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE) ||
+           cmdline_find_option_bool("nokaslr"))
                goto skip_protect;

        for (i = 0; i < ehdr.e_phnum; i++) {
@@ -481,8 +482,10 @@ asmlinkage __visible void *extract_kernel(void
*rmode, memptr heap,
         * If KASLR is disabled input and output regions may overlap.
         * In this case we need to map region excutable as well.
         */
-       unsigned long map_flags = MAP_ALLOC | MAP_WRITE |
-                       (IS_ENABLED(CONFIG_RANDOMIZE_BASE) ? 0 : MAP_EXEC);
+       unsigned long map_flags = MAP_ALLOC | MAP_WRITE;
+       if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE) ||
+           cmdline_find_option_bool("nokaslr"))
+               map_flags |= MAP_EXEC;
        phys_addr = kernel_add_identity_map(phys_addr,
                                            phys_addr + needed_size,
                                            map_flags);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ