Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1828570imm; Mon, 3 Sep 2018 10:29:22 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb/mSj2ZohdjHMioZUwBEwZ8v6Cdjvn3JkJ7Mh2SJb63+P4auhKebcAh1q68RR/STZxVRfH X-Received: by 2002:a17:902:9a0c:: with SMTP id v12-v6mr5109579plp.159.1535995762065; Mon, 03 Sep 2018 10:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995762; cv=none; d=google.com; s=arc-20160816; b=uTSXVYlPOeBmTsYKCkZCbereCWNQMManBClRKS6372W8FlXT2xG4VwUCeN/QlB0pz5 OK5VLh+wkqDVJSU8o7h1jI7FTZhHKQdSVzrKsjPPc8h+wq6ZWTPjWWx3vsaXRfUa5CHC s4KwLxgJKhuQ+RdiH4Hqgr9pINnZjTxDUhHmngcSpZbklMwGQdm9orwKwLHuHYRlQ5Z6 KkrzOZRk8uCdLkNnIvcSfrHfz2F6Pwg7f777sz1V/Tw42QIAVrue6zB998Mlx3TDWQ7N 6eb8JG2GOqenmmbTVtk7wEREJ6aQ73LKFIhm6EGB4JvijCJk8eWGMu570j/1F3e+Og2Z 610Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=CtMl8b/UHpXqoR1MAzk8g1Ev0T8QitD5f/w8Ck8fWVU=; b=muF1y+6oaR7EF9n5douu7UIO5P5LNgLbvf+EDNripkybXaALcaCIHAa6ZUNx3a+RsT xm4HhlE7/2kzOjaa93teUvb2psUQSvUAV2WSfhOL3nprtvoODMl8JgAoqv+dOZSIxJVm KfVwv4I5Zf1mLKGh7oiRxUrItl5TmAVmRt/xN2dvgFqC/pXePt3zVsDUl/2fWbRazDWs /Dmv6XAKkHn4d2BCxDmYdLMn9KvrqjQr4yuiCXdoZMTxE32V4wikTw5dQJ3i4JnqdcUT UkFmuNjnKqHdBBLkhFccYGwPs+Wziukl1UDuCbq07o9bsCwIaocZkVNMNI6BwP+lNiHp TUIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si18520586pgh.307.2018.09.03.10.29.06; Mon, 03 Sep 2018 10:29:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731055AbeICVsq (ORCPT + 99 others); Mon, 3 Sep 2018 17:48:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46302 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728175AbeICVsp (ORCPT ); Mon, 3 Sep 2018 17:48:45 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 525F3CF4; Mon, 3 Sep 2018 17:27:37 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Schwarzmeier , Jarkko Sakkinen Subject: [PATCH 4.14 153/165] tpm: Return the actual size when receiving an unsupported command Date: Mon, 3 Sep 2018 18:57:19 +0200 Message-Id: <20180903165704.757026790@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ricardo Schwarzmeier commit 36a11029b07ee30bdc4553274d0efea645ed9d91 upstream. The userpace expects to read the number of bytes stated in the header. Returning the size of the buffer instead would be unexpected. Cc: stable@vger.kernel.org Fixes: 095531f891e6 ("tpm: return a TPM_RC_COMMAND_CODE response if command is not implemented") Signed-off-by: Ricardo Schwarzmeier Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -423,7 +423,7 @@ static ssize_t tpm_try_transmit(struct t header->tag = cpu_to_be16(TPM2_ST_NO_SESSIONS); header->return_code = cpu_to_be32(TPM2_RC_COMMAND_CODE | TSS2_RESMGR_TPM_RC_LAYER); - return bufsiz; + return sizeof(*header); } if (bufsiz > TPM_BUFSIZE)