Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4509839ybp; Mon, 7 Oct 2019 09:28:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4P30I4Pgt3e0z7SWFLmVc5I3saP9zuj5+NjPhgihzJO4gqUprRUJbGtAFcUB7j8qa74gm X-Received: by 2002:a50:8b61:: with SMTP id l88mr9316734edl.244.1570465725428; Mon, 07 Oct 2019 09:28:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570465725; cv=none; d=google.com; s=arc-20160816; b=rc9jfMKc9D/BbXshDAk5FIupMbfhFkzMTzktjR+EUMD86NK4JBrr7UjxrAZyh9htKv JK2YOLsS4tVBVHapZsxVoUizl+EnWHWpBGooWQWL/ZtME4B5P0EUn1aoZa04kOLiBWNU lhG2VxJOMp0rvIfJGQac5eNuxp+YMJjpqdv02ihLLIY9JP/k487HhpwfriY9sOlyBjV3 aOz0xHeI0VU7MD7bx2PgkvG0Um2RK75SovuS8r+qExgRq/rOIpOChrbHWsQN/FBkqQNJ QweVAIZMOUBeE5+HQQGTaCg272lLyb++M+1XF/KRjXwcphIzGtne3O3sH3AC18F7nU0Z gaoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=PMlIdZe0tafGlH4Uo3oE7bPvqYHG4BVme2hKO40zQS4=; b=eXbo/gbmPkMt79Gl91A1p8J/0P4rj/Gav3zvvOy3w0lwqqpkmA5uYnjDlFtGGxqEb7 kL21wSBOWdvJBEXbGjo6kiM6Os3zGyVvXW/ehEWwTmWUewISUMmlc1c1a3UWyAxREYt8 glmEu+lgy6+F5Awh81q02w74a5NH1JvitAM/luCw2RLrHkQIhs82V+zRdFj/lOnh0gSZ UUKmleNbOijXqDAW0fl/WOdaH5vQQCjRfIYMWHWnvh3VYvaboL2QAYyZXagJjtBnjXF/ TZ4LAtxEQlkRa2KrWLRYGVHXujAUbdM9eeHf7lINRP4pZau3ZYzPcba+VbZM5ttpbecn wCQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=NdJbYHTK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7si10005825edi.318.2019.10.07.09.28.22; Mon, 07 Oct 2019 09:28:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=NdJbYHTK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728264AbfJGQ0D (ORCPT + 99 others); Mon, 7 Oct 2019 12:26:03 -0400 Received: from mail.skyhub.de ([5.9.137.197]:56098 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727801AbfJGQ0D (ORCPT ); Mon, 7 Oct 2019 12:26:03 -0400 Received: from zn.tnic (p200300EC2F06420085D86D94306C6599.dip0.t-ipconnect.de [IPv6:2003:ec:2f06:4200:85d8:6d94:306c:6599]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 2D3E91EC0BEA; Mon, 7 Oct 2019 18:25:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1570465558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=PMlIdZe0tafGlH4Uo3oE7bPvqYHG4BVme2hKO40zQS4=; b=NdJbYHTKsOKpZZNBsd9O9Ims8vs9qNkUadLzrXUm36uhAC+njPtSnt60iN5PAl4DCQcJRt v+lmfWNNOKTiuv5zlxuTFKBm+6RiBOULXu0FUux+cPy2FTXkkoVG2mSn8BBZAAvpNA7FqL ckzS5Lm2wTXVnQ57gnvKBMUsa3VI/Cg= Date: Mon, 7 Oct 2019 18:25:51 +0200 From: Borislav Petkov To: Ralf Ramsauer Cc: Jan Kiszka , x86@kernel.org, jailhouse-dev@googlegroups.com, linux-kernel@vger.kernel.org, Ingo Molnar , "H . Peter Anvin" Subject: Re: [PATCH v5 1/2] x86/jailhouse: improve setup data version comparison Message-ID: <20191007162551.GC24289@zn.tnic> References: <20191007123819.161432-1-ralf.ramsauer@oth-regensburg.de> <20191007123819.161432-2-ralf.ramsauer@oth-regensburg.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191007123819.161432-2-ralf.ramsauer@oth-regensburg.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 07, 2019 at 02:38:18PM +0200, Ralf Ramsauer wrote: > We will soon introduce a new setup_data version and extend the Who is "We"? There a couple more "we" below. Can you please rewrite that commit message in passive voice and thus dispense my confusion about who's "we"? :) > structure. This requires some preparational work for the sanity check of > the header and the check of the version. > > Use the following strategy: > > 1. Ensure that the header declares at least enough space for the version > and the compatible_version as we must hold that fields for any > version. Furthermore, the location and semantics of those fields will > never change. > > 2. Copy over data -- as much as we can. The length is either limited by > the header length, or the length of setup_data. > > 3. Things are now in place -- sanity check if the header length complies > the actual version. > > For future versions of the setup_data, only step 3 requires alignment. > > Signed-off-by: Ralf Ramsauer > Reviewed-by: Jan Kiszka > --- > arch/x86/include/uapi/asm/bootparam.h | 22 +++++++----- > arch/x86/kernel/jailhouse.c | 50 +++++++++++++++++---------- > 2 files changed, 44 insertions(+), 28 deletions(-) ... > @@ -180,13 +175,26 @@ static void __init jailhouse_init_platform(void) > if (!pa_data) > panic("Jailhouse: No valid setup data found"); > > - if (setup_data.compatible_version > JAILHOUSE_SETUP_REQUIRED_VERSION) > - panic("Jailhouse: Unsupported setup data structure"); > + /* setup data must at least contain the header */ > + if (header.len < sizeof(setup_data.hdr)) > + goto unsupported; > > - pmtmr_ioport = setup_data.pm_timer_address; > + pa_data += offsetof(struct setup_data, data); > + setup_data_len = min(sizeof(setup_data), (unsigned long)header.len); Checkpatch makes sense here: WARNING: min() should probably be min_t(unsigned long, sizeof(setup_data), header.len) #165: FILE: arch/x86/kernel/jailhouse.c:183: + setup_data_len = min(sizeof(setup_data), (unsigned long)header.len); -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette