From nobody Mon Feb 9 15:45:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1620310297; cv=none; d=zohomail.com; s=zohoarc; b=iGouHGdOXAC5vPDQNgD2tr75XfLfIgVP4XfzYqKqLBxskAIxJ31Zh74myq1XRRMwLhYG2cChRrltp7JBHkFFGtl7HwDX8QlTeg7NsMOaPaP8su90gA7v7IrDnpLYAgHUiGyDiHrEGfXlxSZ5uPWXRFlnY/7Z1osts/0KrtIwK1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620310297; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/E99YQTRx0RTZe0/WLzL6pyfS/6uYlG8h+BkItkooCA=; b=AYvhQ9lSqBAuk33S4GJuxEyf6egwp0/G0XR+MJBxOgFIFc1SP+wWC3p0PQp1um9qN3kEY2WWCVm4v35ja59oCSYuobMygQ+gHlQXzuDqQRyAli1XoaJBRT5VDKJLJHYDgAd8tiQI1QlGPfiltrmDVyQEzZcxiL04H0XtgaXFFA8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620310297103228.29040526470965; Thu, 6 May 2021 07:11:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.123594.233144 (Exim 4.92) (envelope-from ) id 1leeir-0005XJ-Hu; Thu, 06 May 2021 14:11:25 +0000 Received: by outflank-mailman (output) from mailman id 123594.233144; Thu, 06 May 2021 14:11:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1leeir-0005XC-EF; Thu, 06 May 2021 14:11:25 +0000 Received: by outflank-mailman (input) for mailman id 123594; Thu, 06 May 2021 14:11:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1leeYc-0003iB-OS for xen-devel@lists.xenproject.org; Thu, 06 May 2021 14:00:50 +0000 Received: from mail-qv1-xf32.google.com (unknown [2607:f8b0:4864:20::f32]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3f2608d6-893c-4fef-a0dc-3062f788dbe2; Thu, 06 May 2021 14:00:07 +0000 (UTC) Received: by mail-qv1-xf32.google.com with SMTP id i8so3089726qvv.0 for ; Thu, 06 May 2021 07:00:07 -0700 (PDT) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:6095:81da:832e:3929]) by smtp.gmail.com with ESMTPSA id 189sm2069992qkh.99.2021.05.06.07.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 07:00:06 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3f2608d6-893c-4fef-a0dc-3062f788dbe2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/E99YQTRx0RTZe0/WLzL6pyfS/6uYlG8h+BkItkooCA=; b=UaCztVZ/FvgmmGfmCyRvuOBoUlaURs6FyQg4qli38IOSMD2KRlepGKyjkoUZQoPNLz lKHaRMoQiD0JsidacRHL+lDV7hJLYzEufuD0VzEyZ4n3MPg2UfG/0zJcNBR3Ca6myBTG sxg1oUbygQfedRgXWi19MI7621vvkuKeqw4uq82nV1wsF/ph+mzW0xFxYnArgHu+Ha1l ry9VCBRbrw3kDRaYlou3tg2T+zsItnOKPy2EKfoQpVjyjL07O7bQowF3ndNdESIjW4lM F5D05iQ3AKf6eMRoRHG5v3I7G3pELEwPxWVbSWtrPMl/YZRvFGKGzrVVeaoQ7fHVGz9I TUMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/E99YQTRx0RTZe0/WLzL6pyfS/6uYlG8h+BkItkooCA=; b=CisDO9qDcWcI41/9/g7zxouud4tVGCzSEGM6zH09mEDHrBJlrV35pE/HdSaRKB0sEp Bl6HClJxXF/A1OENLo4LIqxtqUg8QelYzpPo5RqPCuQAlvuxY7KofvQEeSGraOdKM0UJ c1N10OHBfBYhyO9vAdtNdkzF8lSojwRqACdAmiNoF/6ZnU2md/kbyzWRiBX3kyvpArhg siuuusmbZ2THYBHXNNfbr38Yv2Gheoo3TY6G/rWi55e3+UcMCOKoBWMAxeHPwcKK4I1z uihe65n+sm83z5DqPF5ExKb86JZ3+dzcS8Eh8XeKar7UClC8fvQKKFLNQdW0nIByX0UY ZDJg== X-Gm-Message-State: AOAM531SCcfg5i7a9gawC2JNW+yuOMVCKkmgyH8sj281+pjeb4CZwleR NIByq7wfvFOG/ggimSG3MJPIvrtJu8w= X-Google-Smtp-Source: ABdhPJxleNtmX+v0KHt/6+jkeldv+4xkcWlSn4GhoIc/oVW82SbEtnz/Kcgb+4eNSUSrCMmthwqHgg== X-Received: by 2002:a05:6214:241:: with SMTP id k1mr4430410qvt.29.1620309607051; Thu, 06 May 2021 07:00:07 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Daniel De Graaf , Quan Xu , Samuel Thibault Subject: [PATCH v2 12/13] vtpmmgr: Check req_len before unpacking command Date: Thu, 6 May 2021 09:59:22 -0400 Message-Id: <20210506135923.161427-13-jandryuk@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210506135923.161427-1-jandryuk@gmail.com> References: <20210506135923.161427-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" vtpm_handle_cmd doesn't ensure there is enough space before unpacking the req buffer. Add a minimum size check. Called functions will have to do their own checking if they need more data from the request. The error case is tricky since abort_egress wants to rely with a corresponding tag. Just hardcode TPM_TAG_RQU_COMMAND since the vtpm is sending in malformed commands in the first place. Signed-off-by: Jason Andryuk Reviewed-by: Daniel P. Smith Reviewed-by: Samuel Thibault --- stubdom/vtpmmgr/vtpm_cmd_handler.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stubdom/vtpmmgr/vtpm_cmd_handler.c b/stubdom/vtpmmgr/vtpm_cmd_= handler.c index c879b24c13..5586be6997 100644 --- a/stubdom/vtpmmgr/vtpm_cmd_handler.c +++ b/stubdom/vtpmmgr/vtpm_cmd_handler.c @@ -840,6 +840,12 @@ TPM_RESULT vtpmmgr_handle_cmd( UINT32 size; TPM_COMMAND_CODE ord; =20 + if (tpmcmd->req_len < sizeof_TPM_RQU_HEADER(tpmcmd->req)) { + status =3D TPM_BAD_PARAMETER; + tag =3D TPM_TAG_RQU_COMMAND; + goto abort_egress; + } + unpack_TPM_RQU_HEADER(tpmcmd->req, &tag, &size, &ord); =20 --=20 2.30.2