From patchwork Mon May 17 13:58:33 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: 440110 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1138920jac; Mon, 17 May 2021 07:25:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEm0OC2XpL78WugfqRoO48mayUkstwQ7v3X32IP4bjWgU2ryV6k+vx04pgoO8eJtR1CqvL X-Received: by 2002:a17:906:1d43:: with SMTP id o3mr179636ejh.466.1621261505792; Mon, 17 May 2021 07:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621261505; cv=none; d=google.com; s=arc-20160816; b=yXwHVgZWmKFH55KwxA72mIdHanHIRx15TEgrgEofCKhzUdB7CPzIGJFYto49g7aXUX AUquwl3xcXkuFi5uWvIxgJ2OQB0x4iQMEVPbf10USMW/CUx8PdEZ3Qba5k4v3h2EbCLJ 7reUrl3MlY4u6K6ctEb8o9tn0TthWTWFSt0xF0TfdYusjb/15u6BbLOPSi/lhJTNI2x+ GM4B0aET5T6EcjukdaBYwPbVoCgITvl4z5BGPLhN2XAVw8pydYgU5OQNknFA1TWkgHbn W6tnv7z9MryxWd6FoH/kvKrdz9LC2kVDUA83+fxe4Ovj+uGSQBRcumRPaqHFZPu6DH/d m6CQ== 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=lhBAFQiFdk9FUzenr4NLS4HXL1JD1nxrW22HpShK2dg=; b=n4Jq/h/1UU8Lln83aSlXHezAOWYjTU2kpBiVu17UtBtbhN3c1+tNTQ4iFos+SD8Rog Vxbuk1dw8JfmiQZjyqi+VGJRt15MncTdz3jU+3SsCo9tV7zBc0hN4w5biGan9JtL88if 6CpV/bB3yqJXohlyOwM8tome3Q1nxf6nlmBGtR3/bKH3LRJne6d1ztnUwNoTzzmPAbF3 8JrWIjS/2Pq6u35AKfAJfpuxSR++xOoIRaXV7fo6g/pSOC7sbu+8x+JeX4AJFU1wiEcF njs1RqvQmNd4oXiRm3mQI4QEQmr1aQ9MA6qoV+7hx+YOh7zdEjE40RHgZ5s0VDaHzw9T qV8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GueaJEp/"; 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 d5si380962ejt.21.2021.05.17.07.25.05; Mon, 17 May 2021 07:25:05 -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="GueaJEp/"; 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 S239439AbhEQO0T (ORCPT + 12 others); Mon, 17 May 2021 10:26:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:53884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239544AbhEQOYX (ORCPT ); Mon, 17 May 2021 10:24:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A98BF61461; Mon, 17 May 2021 14:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260776; bh=jSsfYsjOAK5vnwE44c3ptQAHVaPrn3/ES+jLwvO6c4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GueaJEp/C7TUawCiTO+Go2q60r0NO5kAYl8ZskIkBY7tthyP6L4cEq+8tUiJ60ebs SxHAqtUqAa0/RzqXA/HWytUSLIqQbcF9xtt1bE0FlV6tv/aDh89252yMy4bJKgQ/dO rBmEfLyb7d5VifR5XY+xpOjsAYThH0sxW62sp0VY= 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 5.11 002/329] tpm: fix error return code in tpm2_get_cc_attrs_tbl() Date: Mon, 17 May 2021 15:58:33 +0200 Message-Id: <20210517140302.124451298@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.043055203@linuxfoundation.org> References: <20210517140302.043055203@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 @@ -656,6 +656,7 @@ int tpm2_get_cc_attrs_tbl(struct tpm_chi if (nr_commands != be32_to_cpup((__be32 *)&buf.data[TPM_HEADER_SIZE + 5])) { + rc = -EFAULT; tpm_buf_destroy(&buf); goto out; }