From patchwork Thu May 20 09:22:05 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: 443210 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp2160666jac; Thu, 20 May 2021 03:36:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd0BeghG55QivHJgkHZIUQVFr4C4N7vUH3DP75xTddQ2Afd1aAxA28KznPlOwLAaFDz56t X-Received: by 2002:aa7:d2d4:: with SMTP id k20mr4164082edr.384.1621506960542; Thu, 20 May 2021 03:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621506960; cv=none; d=google.com; s=arc-20160816; b=qM6YwD4jRqpt0rfRyFonH4t4nmpl1UrF68qbTxDb53r1XAwU0d5MnNXo/49yz65vWz +/4DWwCc0kFvc1ClAT8drIGKy3r7Qz4GtO53q2/x/cPqfuF05Dw7p/wJNPouczwSeKQw 2/wFvrsVsi5stXL16D4lW11hLlmMWaVTKxi5JNo7HaCrgiWxG0uCovNEz8atp7YacfDe OlulKyGdGv9IaS8xhdoBhsCRc3i/f5152rhzNAD1Ar1iqty76eDsY0176hggUHGq98KA Z5EV0LNBhvSMJECpvEvTZLiCH9zMtaLK6eKbIdo4uJAKCe2XODEGlBSl9tqiGl8ll+5K eD7A== 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=M29IcWRDL5L/UxOPrmUO8jF+xYx5J7PkyaDWimr72lw=; b=RB0nLpDHX6nK9cVtd9WtaKss5Asd6z/am1mUai3DDpseR3JT/GubfhicIIwAUWCTMU njYlYe1FN0QxL1xmdAUZwnk5rnRsHP2/PGLxx/aspSA7MuD8cjqLamgXTC4iRTTtkeV4 pS4l5rqJUDzBeMzgIrT2TZFvJi5Zd6K24pu/QhcMhluuDuxWjRFk6scqJI+NzmUZ2f+D t4Q3jb2X0tZBLZZ4Tw1HyOp79R+Lhja8rJe2bGVgAnhiZ9RmSJu3Q1hX9NAxtuCCQ7nx 8UM0+sHOi6UGTO2eexfJ8tajQKy921zU2MDVxXYlWt3qM+NMX+yD6s8YrRvXWqW23K4p TgVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fHEuk286; 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 dn20si2808920ejc.125.2021.05.20.03.36.00; Thu, 20 May 2021 03:36:00 -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=fHEuk286; 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 S237468AbhETKhQ (ORCPT + 12 others); Thu, 20 May 2021 06:37:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:39660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237696AbhETKfT (ORCPT ); Thu, 20 May 2021 06:35:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B29C61621; Thu, 20 May 2021 09:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504413; bh=2VQ4lbtPbGdQsa4zQm0fVzFo92ffNQnqn4D6SswZcco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fHEuk286zj2BeZnx4YhGbOXU/+kzieNNSjNQPwxgYkUjDuR42a2G4HWGRFRlugI9m 9OsKmXtQvl9wmPUAMTHmVYNAjAxjU/v+4TG57QPJx10NbvitThCoDi7yfSAoS50XxE djSw0kMVJkGn/lepH7UCfFYugwsvTQ26vFmV0O0s= 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.14 233/323] tpm: fix error return code in tpm2_get_cc_attrs_tbl() Date: Thu, 20 May 2021 11:22:05 +0200 Message-Id: <20210520092128.144394142@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 @@ -1051,6 +1051,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; }