From patchwork Mon May 17 13:58:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 440116 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1156585jac; Mon, 17 May 2021 07:46:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVEP9eMv8T7DTi5qb0hCdAhqS1cLkWX9SUDieZpLf7gzGDSEiwkB5aeC9ZoX8bffYmTIqA X-Received: by 2002:a02:ab87:: with SMTP id t7mr338559jan.57.1621262809462; Mon, 17 May 2021 07:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621262809; cv=none; d=google.com; s=arc-20160816; b=FQk+Ta378NOPUTrIQuhgv576Igc0683dQ4ERkygYTJENyYB/24Me11HIpgNcae8jpQ pPZos/AECYNnoiQgiw8VAK3Fx/mh11psoAzG0CT7Dkz/i0Gis11cevhBx0nnMNIMRsoQ FVAm1hSuQBTSq7J5qBpeDDsGFuUbvbsALKdlnaUVF/EFthBuJAVJ2Mt8y1X1Q3Ytb414 VGy4MNMQJ8qPnsTiARtgjQhyaWaa/shEWkZkd+J+L+xjuxhEBAiI+w7lCxaD4HzYztzv pb9LF6AHrLPIueeUBxn+2R8wmBScGBzMloTwWHkyEn7qhzlaZ/+OsLmtySlNwWq8jc5h gM+g== 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=Yj5LswvORYme5Tqj/rOPR/0QkBZ+3PGqacYyqjlE3duIyibQAbqNU0GLNE5Eru0jb1 4hDDnaVdZyTXAZlYjOKjoH1zwhLJuuuMxmNu3mHcW7Zhf2i2oHWgh5L15Fv+I/LKrQwP CJbD98eyrQFWbXKB8xfinOxMBiI090s4OfCQAmGkbg3aJRJwuSqJtIoTgGaif/7CL08n h6tf2O2EHI/7B+ZlOn0CnEWe/iDjqcggUMMi4cWKO3Njaa+LOMM7+xML3NFzc2rTKMOc t5nAhYeOtHDp5pRI2x6sdDfDpxLMNtve96Yh4ZvhIC11IdfunN9yFWqOBrbfqc5th9Hr +nbg== 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 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 h127si15352205iof.102.2021.05.17.07.46.49; Mon, 17 May 2021 07:46:49 -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=TzEZ3lUu; 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 S241200AbhEQOsD (ORCPT + 12 others); Mon, 17 May 2021 10:48:03 -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 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; }