Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752899AbcDRQu0 (ORCPT ); Mon, 18 Apr 2016 12:50:26 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38770 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752378AbcDRQuZ (ORCPT ); Mon, 18 Apr 2016 12:50:25 -0400 MIME-Version: 1.0 In-Reply-To: <20160415080956.GE30715@gmail.com> References: <1460672954-32567-1-git-send-email-keescook@chromium.org> <1460672954-32567-5-git-send-email-keescook@chromium.org> <20160415080956.GE30715@gmail.com> Date: Mon, 18 Apr 2016 09:50:23 -0700 X-Google-Sender-Auth: FHtroxW8IlR3CBTW7Yv4Sxyjyb8 Message-ID: Subject: Re: [PATCH v5 04/21] x86, boot: Move compressed kernel to end of decompression buffer From: Kees Cook To: Ingo Molnar Cc: Yinghai Lu , Baoquan He , Ard Biesheuvel , Matt Redfearn , "x86@kernel.org" , "H. Peter Anvin" , Ingo Molnar , Borislav Petkov , Vivek Goyal , Andy Lutomirski , Lasse Collin , Andrew Morton , Dave Young , "kernel-hardening@lists.openwall.com" , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1937 Lines: 54 On Fri, Apr 15, 2016 at 1:09 AM, Ingo Molnar wrote: > > * Kees Cook wrote: > >> From: Yinghai Lu >> >> This change makes later calculations about where the kernel is located >> easier to reason about. To better understand this change, we must first >> clarify what VO and ZO are. They were introduced in commits by hpa: >> >> 77d1a49 x86, boot: make symbols from the main vmlinux available >> 37ba7ab x86, boot: make kernel_alignment adjustable; new bzImage fields >> >> Specifically: >> >> VO: >> - uncompressed kernel image >> - size: VO__end - VO__text ("VO_INIT_SIZE" define) >> >> ZO: >> - bootable compressed kernel image (boot/compressed/vmlinux) >> - head text + compressed kernel (VO and relocs table) + decompressor code >> - size: ZO__end - ZO_startup_32 ("ZO_INIT_SIZE" define, though see below) >> >> The INIT_SIZE definition is used to find the larger of the two image sizes: >> >> #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset) >> #define VO_INIT_SIZE (VO__end - VO__text) >> #if ZO_INIT_SIZE > VO_INIT_SIZE >> #define INIT_SIZE ZO_INIT_SIZE >> #else >> #define INIT_SIZE VO_INIT_SIZE >> #endif > > Please also harmonize all the prefixes, i.e. use VO__/ZO__ everywhere (rename > things where necessary), instead of this mixed up VO_/ZO_/VO__/ZO__ mess. I'm going to leave these as they are: they're auto-generated based on various functions of interest: boot/Makefile:sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|z_.*\)$$/\#define ZO_\2 0x\1/p' i.e. ZO__end is _end's location. ZO_input_data is input_data's position. I think it would further complicate things if we tried to consolidate consecutive "_"s, or if we eliminated the leading "_" (ZOinput_data and ZO_end). -Kees -- Kees Cook Chrome OS & Brillo Security