Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp455999pxj; Thu, 20 May 2021 13:22:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn9Y1fzBmVdw+H2hOt+enl6lMePc0iXbvrKhUWqTHMzO8E8jo7v83HJoRsOjDnu01NZWeY X-Received: by 2002:a92:7f07:: with SMTP id a7mr6512688ild.202.1621542132201; Thu, 20 May 2021 13:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621542132; cv=none; d=google.com; s=arc-20160816; b=H8pf+ta8yuTHF0D0GJFgS2saOuenvUogWUjTMveQMk2h7XQtzUA+1QZviwo3U1ifIK Ij+RlRry9XlKPozDVkrUFjN1lv/Z/8WMP11QivYRQrQm2IPt+mzsJKZ3Un7VZLU5I8WH 1nnqunUXAdUpb4PJp4vBEhCPXFVgU3LWmd/zDXlGevF31FhirobzZeqzYPtop1pIKAhK 4jPRhdtQbzVs94C0rUHVGOAuPdD9Mm7bvVoVG8e8UBBA66MtrRPQlk+MswKuJRDfRmVf /0DEHZVDd0BIpZ/U+j681l+dJ7/Qcb8NMv17rcLdDso579lUbZh1+hZZeMMbkdjQi10g zGCw== 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=XGJedwiWp1cgFPkNAXWv8kJRjDxrZpv3BKG2WFEDiuQ7EX6I8VyXaIdYhZ1YRiq0Iv rOzGUT2lg8xs2wrJMB4SVgOZGwvfDp3l9Gn1pBQ2o92sF1pfQzZQcKIbhKdsbJIG2O1N pH09+g66Lwk1ahnkxSqr6Kj9JL6sh0bgrySbADPcb/BsFfLJ5k2wymP3tSi4PKPHY9Qm ZdtWhTkQPMV9XSfocOpvkKCfwIZr3qCu9g7JFJdQt2gsX90WCwx+nx+zYsMqIGQXHwj5 TBsHy7PzD5yDuzQFQmgcYd917hR96w/1dlVJ9WJxypujpJZoRBGoPhIZJ/UmeaG08HUH FnLw== 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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 p10si3435741ilq.156.2021.05.20.13.21.59; Thu, 20 May 2021 13:22:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S239001AbhETKuq (ORCPT + 99 others); Thu, 20 May 2021 06:50:46 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; }