Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753870AbcDOJFX (ORCPT ); Fri, 15 Apr 2016 05:05:23 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35967 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751517AbcDOJFU (ORCPT ); Fri, 15 Apr 2016 05:05:20 -0400 Date: Fri, 15 Apr 2016 11:05:15 +0200 From: Ingo Molnar To: Kees Cook 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@tukaani.org, Andrew Morton , Dave Young , kernel-hardening@lists.openwall.com, LKML Subject: Re: [PATCH v5 04/21] x86, boot: Move compressed kernel to end of decompression buffer Message-ID: <20160415090514.GA9314@gmail.com> References: <1460672954-32567-1-git-send-email-keescook@chromium.org> <1460672954-32567-5-git-send-email-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460672954-32567-5-git-send-email-keescook@chromium.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1871 Lines: 40 * Kees Cook wrote: > When INIT_SIZE is bigger than VO_INIT_SIZE (uncommon but possible), > the copied ZO occupies the memory from extract_offset to the end of > decompression buffer. It overlaps with the soon-to-be-uncompressed kernel > like this: > > |-----compressed kernel image------| > V V > 0 extract_offset +INIT_SIZE > |-----------|---------------|-------------------------|--------| > | | | | > VO__text startup_32 of ZO VO__end ZO__end > ^ ^ > |-------uncompressed kernel image---------| > > When INIT_SIZE is equal to VO_INIT_SIZE (likely) there's still space > left from end of ZO to the end of decompressing buffer, like below. > > |-compressed kernel image-| > V V > 0 extract_offset +INIT_SIZE > |-----------|---------------|-------------------------|--------| > | | | | > VO__text startup_32 of ZO ZO__end VO__end > ^ ^ > |------------uncompressed kernel image-------------| > > To simplify calculations and avoid special cases, it is cleaner to > always place the compressed kernel image in memory so that ZO__end > is at the end of the decompression buffer, instead of placing that > start extract_offset as is currently done. Btw., it would be nice to also put such a visualization (of the current layout of these values) into the code itself. Thanks, Ingo