From patchwork Thu May 20 09:21:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 443196 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp2137690jac; Thu, 20 May 2021 03:04:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkozZ1v0nvqj96xIcHnR0UedBgUZ57ORegHtmFSNbbKyxLO8kzG/uOZT4PfE23hWOUR+ev X-Received: by 2002:a5d:8501:: with SMTP id q1mr4695362ion.66.1621505078047; Thu, 20 May 2021 03:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621505078; cv=none; d=google.com; s=arc-20160816; b=Av4M3kJif052xcDydsL4HtQrng2RxuqsYBUBYsda//ll5Qc6wK1qfVHEGapwBfifuR n/lwolB0SSNjdxGFomUTEEF5/WS3GhbtXQ8jVf04xVuGZDhnsslipuJyA4aHf/tFiJt8 XRwen50JBIBZCUWU6yys5va5dnGRRMPwWCQtKufPdx5gJ/MejwKRRFj86/2E2UMGqDdD Fq1syJZGCO3PxBWLSURVx68F5LFPT2ZYBXiIguIaMxF6+Ae3uhgs6FT9U3gvNQjRTJqi 7VBUjEaytzRBFjPOwZiWkoG55TUviEC2VY3dKrqh7LrS7qIdIvvFexALsCENzhcFzbje gc9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WyBJXtnaQ3JTtvSmxCBSIQnxS4veYiBRiZ8FypsPZiE=; b=j+ML+beye7rpd5pavBgccgb82MicldI+QtfcOTvd2EkL/ykP7n1JtbU3eXPArcbivQ dpjAwnzIlIFvcc1NXCCNbpW6rZR1t13Rdnm74Ik/S8vSGRZxQSucr0SU6OiGMSlCgpzT N7eqWrsgngDu3Pa8GM5FdD1AIk/wEdFCyVVosq2+iU89YHpH/dsSF4EDIpQjnUPyLpq/ aDtOKIBUaepAQJxYXT6AYjUGQzwXEn9qbNNuZf9KOsvSR8GlAO2dxyxbGO8ttulPxEQE OqizfnSqrnQMfsBQJxTF3crNNzxChS5iC+ogn6UWK6MxrP5o8Ng3mvIvnmrMxkB8G2g6 IDkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vcajhou5; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o10si2162889ilc.147.2021.05.20.03.04.37; Thu, 20 May 2021 03:04:38 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vcajhou5; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235151AbhETKF5 (ORCPT + 12 others); Thu, 20 May 2021 06:05:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:37146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234842AbhETKDt (ORCPT ); Thu, 20 May 2021 06:03:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 45A9261436; Thu, 20 May 2021 09:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503612; bh=8bt1rxsdBuhk6fJ7h+cvc96ta+J82W0P13xVGWt59p8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vcajhou5R+Kuz/B0YN5AlQG2Oaj5V/frWI4KvcsZcCbMX1pwPel6TEhcXKKlWlfSH PqLF1Z3YXBTHmwd4LBQMmu7Blv76fvsY4f8YBPLKJ9QZEk3/fm5b2Sg+3Gbdc5dI3A og31YDV7IBd70HgyBLn9TXUU1pRQ2qY4k+R3dQTc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zhen Lei , Jarkko Sakkinen Subject: [PATCH 4.19 301/425] tpm: fix error return code in tpm2_get_cc_attrs_tbl() Date: Thu, 20 May 2021 11:21:10 +0200 Message-Id: <20210520092141.335771105@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Zhen Lei commit 1df83992d977355177810c2b711afc30546c81ce upstream. If the total number of commands queried through TPM2_CAP_COMMANDS is different from that queried through TPM2_CC_GET_CAPABILITY, it indicates an unknown error. In this case, an appropriate error code -EFAULT should be returned. However, we currently do not explicitly assign this error code to 'rc'. As a result, 0 was incorrectly returned. Cc: stable@vger.kernel.org Fixes: 58472f5cd4f6("tpm: validate TPM 2.0 commands") Reported-by: Hulk Robot Signed-off-by: Zhen Lei Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm2-cmd.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -960,6 +960,7 @@ static int tpm2_get_cc_attrs_tbl(struct if (nr_commands != be32_to_cpup((__be32 *)&buf.data[TPM_HEADER_SIZE + 5])) { + rc = -EFAULT; tpm_buf_destroy(&buf); goto out; }