Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5747067ybe; Tue, 10 Sep 2019 08:14:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9GfxFzueR6ZPSS5ZTt9Q/+MoLCVOeHVwgWnGWn/QicU3En9hR1GN0zLjujjPor6chJt/8 X-Received: by 2002:a50:852c:: with SMTP id 41mr19473325edr.201.1568128455241; Tue, 10 Sep 2019 08:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568128455; cv=none; d=google.com; s=arc-20160816; b=tOHZUW7pstm9qwxSOqm5d+v4ZgbwMtI5K2OqOHzFSYFZiMdNLC8EdENjHOc3q+z45i DjLMFG1j+e0Xrun6pDB52hr4r6qiajuxLFHkI57L3zhGFC1627yOhzNhrh3cp8lXGceI 0Bg0XUZLKJRDH7MwAn7y82DfplLxT1HI4sTMn8re4HrX+5nHvCJdVte1BhPGKkOOsajW 7XrhF+krU1++HNfa5LvaKxPmpXB2aRN3DmrKhBZlvs8sGCtV5SvbVhNtSG7dNBLHZpys lEVVXDsBZZeDC3YhYA/Z1qBBBoTQLAIL8dbsGm+xP2315c22xHKFiAs1cJwvuw/vJmQV gvMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=mjlmQ8q4ebSGeqcCwGl4CP2ghV+MJ2RVpTWgq9fAfiY=; b=Y+3hgS/jkvoYuOM/YEfMxcvcaY7sNmxloZv8A8oNZy3OnZAuuM0FletezLgMdwjNV3 S49fclACJjzCGCd5fcNKswGmLkopKc2VUGgW0qYjAP+2HJg8+Pp+7PBpDf1BSj5blcNE SnoViHThLQyX42cVBeXeOCK81kkzFcF98ZOlEvyJ+gMH/41UaMkxE7CRmveM20/X5XhQ IfCm/+8ZhoBiemskXQfkCz0am3p71ZUfLlOWpRSKKk1vS1tWVV7J2jSfAi/4Ijr1rRiM SlLSLqoztrAC1M8ThFat0YcS5FIu/n/mOQPh/8F0jbwyXLG6jHnDafYxz60UbMKBC52X KUCA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g23si8918302edr.147.2019.09.10.08.13.50; Tue, 10 Sep 2019 08:14:15 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389225AbfIJPLZ (ORCPT + 99 others); Tue, 10 Sep 2019 11:11:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51678 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732434AbfIJPLZ (ORCPT ); Tue, 10 Sep 2019 11:11:25 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 134B537E80 for ; Tue, 10 Sep 2019 15:11:25 +0000 (UTC) Received: by mail-qt1-f197.google.com with SMTP id m6so20098324qtk.23 for ; Tue, 10 Sep 2019 08:11:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=mjlmQ8q4ebSGeqcCwGl4CP2ghV+MJ2RVpTWgq9fAfiY=; b=aFUhW6vAsekq455eZCuCVLNbehGrSfIc7IpkFl2aMe908ENAIe1cm0RcXQHRTdNjzL gUsd+dIhNu8v6ifNGCpEi0jc7FDuxqmR+b0g3nzwncN21/0DUCjFglMOqkV1QEu0v2rs iZ+X+/3w1dWUL+ICMAEi+4JMr5/kUvUDEMY6XrgrkcfXyyznrjRgYvVTz6g5mYhYz1sI oDRuwFMHwv9StSNalvpo74mBl3GYm+E8W+MmnIp6PF1w8t5suu228LJfxNMlH5HsMV7c qZ7x0bduYzIckXlpBjcEDzAntSh1HTmDQNG8fQxGNBkLKDn227wDY1Pg1Jr0d9MMTmkK pqMQ== X-Gm-Message-State: APjAAAXug4jS4dpIfNxV2A8y2AdKBvLfSXhvBP+XqiI5Yw3WJDJ0hvOq SLyPKAnzdsQVNO3N2S6CfcMlEwzjVhKhD6Fp4I+/iyeZbjw3BS7xFnOKqIWyadOCqyVGwSkdihT /ttmQRt/Me5I5IY+vTqyag4P/ X-Received: by 2002:ad4:4246:: with SMTP id l6mr17975786qvq.140.1568128284314; Tue, 10 Sep 2019 08:11:24 -0700 (PDT) X-Received: by 2002:ad4:4246:: with SMTP id l6mr17975751qvq.140.1568128283949; Tue, 10 Sep 2019 08:11:23 -0700 (PDT) Received: from localhost (ip70-163-223-149.ph.ph.cox.net. [70.163.223.149]) by smtp.gmail.com with ESMTPSA id z72sm10001318qka.115.2019.09.10.08.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2019 08:11:23 -0700 (PDT) Date: Tue, 10 Sep 2019 08:11:21 -0700 From: Jerry Snitselaar To: Jarkko Sakkinen Cc: linux-integrity@vger.kernel.org, stable@vger.kernel.org, Roberto Sassu , Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , open list Subject: Re: [PATCH] tpm: Call tpm_put_ops() when the validation for @digests fails Message-ID: <20190910151121.3tgzwuhrroog5dvb@cantor> Reply-To: Jerry Snitselaar Mail-Followup-To: Jarkko Sakkinen , linux-integrity@vger.kernel.org, stable@vger.kernel.org, Roberto Sassu , Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , open list References: <20190910142437.20889-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190910142437.20889-1-jarkko.sakkinen@linux.intel.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue Sep 10 19, Jarkko Sakkinen wrote: >The chip is not released when the validation for @digests fails. Add >tpm_put_ops() to the failure path. > >Cc: stable@vger.kernel.org >Reported-by: Roberto Sassu >Signed-off-by: Jarkko Sakkinen Reviewed-by: Jerry Snitselaar >--- > drivers/char/tpm/tpm-interface.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > >diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c >index 208e5ba40e6e..c7eeb40feac8 100644 >--- a/drivers/char/tpm/tpm-interface.c >+++ b/drivers/char/tpm/tpm-interface.c >@@ -320,18 +320,22 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, > if (!chip) > return -ENODEV; > >- for (i = 0; i < chip->nr_allocated_banks; i++) >- if (digests[i].alg_id != chip->allocated_banks[i].alg_id) >- return -EINVAL; >+ for (i = 0; i < chip->nr_allocated_banks; i++) { >+ if (digests[i].alg_id != chip->allocated_banks[i].alg_id) { >+ rc = EINVAL; >+ goto out; >+ } >+ } > > if (chip->flags & TPM_CHIP_FLAG_TPM2) { > rc = tpm2_pcr_extend(chip, pcr_idx, digests); >- tpm_put_ops(chip); >- return rc; >+ goto out; > } > > rc = tpm1_pcr_extend(chip, pcr_idx, digests[0].digest, > "attempting extend a PCR value"); >+ >+out: > tpm_put_ops(chip); > return rc; > } >-- >2.20.1 >