Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp176465pxj; Tue, 18 May 2021 00:21:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqr8hE5uOO7THXWR72krpDZoSYaIYrInYiuB/EWgVEzJTY5p1WcwRMuyTSm0f2iHPsX0nh X-Received: by 2002:a17:907:11d1:: with SMTP id va17mr4525650ejb.485.1621322515880; Tue, 18 May 2021 00:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621322515; cv=none; d=google.com; s=arc-20160816; b=H+P8XJ2qoAygHSvGBEu193BzZqsO4RBC21ilzp9XsUAPQ332PbG7QMsqVFnQ9wemwK XJusZBw6PaxwY69Dua192wQW6i7VH2cByFPmsMgLYAthiOXs4Suj2sb3UiWnuQOA7xaW LSOjzfxaOShTfd5B/BBiLiXmyVNHuXVYWMwhKImv6IdZmIvtZF4HLHi3895nKzO+FL+q f5+h9A/L1gBIpatqLMgXlSYp74d72E0Exu/RjlRiQxS5Z/Cc/FPWG4Yw+1Nuj57O3tmz NKaSoeByJdBC/dsgXnIGpI5KcJRxZBxwQx+Ovl7UNlJ1fQkLxy4ah6bNFuW+3L25AKJ3 AM6g== 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=Ob1r6VVTnUWpXsJzO125HT4dOTUVljm9+cCYNX6NS4pMXhA1aGtJ9GxBxPAY7Ay2RJ L53/VLzGHOuNkVFqSM8y2FfvvNtYF11W5flFsIfqLN209VFWHgT+wDQDDxtv1vMbMTDz Pb6qY72v85pLOXWO8r/5EmvqbZMef5BgQd9XwDVx6RzMs2Ot7nGLVY/Ss7fvI/6sgWZu 0OUneUhEmMH+2pOkdtr8nD6xXlnmVJnL773cO6t7mydOYj5j9gozud253to/fs4ktA2y gSr7aAd3lpeRPF9uNkVCi6q0NX99hjLul6UrxQeMSXQYLjWxUWsrSjacR5w11lGf0E2w ccGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TzEZ3lUu; 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 8si19167448ejx.447.2021.05.18.00.21.33; Tue, 18 May 2021 00:21:55 -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=TzEZ3lUu; 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 S242087AbhEQOye (ORCPT + 99 others); Mon, 17 May 2021 10:54:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:56784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241782AbhEQOqB (ORCPT ); Mon, 17 May 2021 10:46:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BA9161966; Mon, 17 May 2021 14:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261292; bh=jSsfYsjOAK5vnwE44c3ptQAHVaPrn3/ES+jLwvO6c4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TzEZ3lUunYkD8cr7Cs3wRB7f9G+jUxii6/NDmireakQTpV1yEjjzWPQbynLcvyPvS 4VMze7+PRaW9FsU0ISS8WG1R7hk/2ya+fctBrEoOcZT2ZYPf4Q/R+IenVTWDRyxzjU 6A6OH4IqSEEh7zbU1yn6JjGL2/zG9rvlRLslNvcg= 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.10 002/289] tpm: fix error return code in tpm2_get_cc_attrs_tbl() Date: Mon, 17 May 2021 15:58:47 +0200 Message-Id: <20210517140305.229967916@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 @@ -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; }