Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp22219ybp; Thu, 3 Oct 2019 09:37:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQkOSANDk3jFqA+zOsrFGEl5t7bGxZ9b/d1y61DcdgbvLwes7FiSD7I4Yvmh0QiruikPSE X-Received: by 2002:a17:906:4544:: with SMTP id s4mr8613102ejq.116.1570120655772; Thu, 03 Oct 2019 09:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570120655; cv=none; d=google.com; s=arc-20160816; b=kGs1u1QD4ZUvHtpmeUP/sJhzjzbPSeQBUXvsfwnHCvar97TUlGAaF3ZiQ/oVOiToHJ LJ+4FSm3LrdhlT3D45zdiXf/0LuNAWKUo5YBYeb5fuJQEn4luL/Nk8El8WxwMMGOXTAF C9oqi6yDnA8QbC3oS1PivwJg5nw23oAhLEO60apGXxIDyHuF38s8gfc3xuy5hueA+qPj OtmLucJl0esrWVAtAcEE7kNWYF5zuPuqxv8EjzkIF7FX9y620R0DqXI2zdEVHicrq/xZ Dch7NGj3IsD8X6nhRt0flMjAq14hAwZDBBu+x8U/9gDQPIW1bbcXeeA9AVi0xWx026v3 V9TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+iPOIBZm9NF6gx4sD0FOghpy0K7E28wHW93WYOyqkJY=; b=PqYJ7pt8YgaDUGoDmMExAlhyYHm3a3+Bii6kGXK+h5zOJsBsCrM5pAZgPxPx0uSR8c u8eGSKK1FSdZbRd8Y10b5AyVPMETJVJp5SDdd2pnbu9AY4ec2O0ybhVAr5FPSF9yayK1 iYMsMs8uz54kmDZdFM37eEj6Kln3NwDrQniONhPkzBZJLILQTsuhMfs6alXb5ypmHTt6 rftOhxK3P741SvEH304RZz6rqJmYvs2xkEt6oXGxfb2x/kyTgkN9KSRRHjXcFkcz485C b04G6E/v61WjFaq5cM52vRlpTxuC+86s4F8J4lW9yYozrguGiJqE9DEPHrRJ1j0gf+Xb 5iDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xfW0IHh+; 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 x51si1808121eda.272.2019.10.03.09.37.10; Thu, 03 Oct 2019 09:37:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=xfW0IHh+; 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 S2404208AbfJCQeg (ORCPT + 99 others); Thu, 3 Oct 2019 12:34:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:43224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404166AbfJCQee (ORCPT ); Thu, 3 Oct 2019 12:34:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B89F820830; Thu, 3 Oct 2019 16:34:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120473; bh=XWcptmxv1SX7IKJ84dhak6NlS0RXPtihWkoO7p8Rfp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xfW0IHh+1adGshqQ4Y30giXLOK1dL3fmfC9vXylZgJHuznjxSMLjnzYP4J1/JKP1t N+vnKd8nSxrxPJ098QMWzwd7F0rKFDchCBMJ8olDE4C7Zq31Yr+gFgrEN5rAj/ErYB MasXaW3Mh6RmqOq2vM+EBrVJEQvcxK6LaPnL2yO8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mimi Zohar , Jarkko Sakkinen , Jerry Snitselaar Subject: [PATCH 5.2 234/313] tpm: Wrap the buffer from the caller to tpm_buf in tpm_send() Date: Thu, 3 Oct 2019 17:53:32 +0200 Message-Id: <20191003154556.053499408@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jarkko Sakkinen commit e13cd21ffd50a07b55dcc4d8c38cedf27f28eaa1 upstream. tpm_send() does not give anymore the result back to the caller. This would require another memcpy(), which kind of tells that the whole approach is somewhat broken. Instead, as Mimi suggested, this commit just wraps the data to the tpm_buf, and thus the result will not go to the garbage. Obviously this assumes from the caller that it passes large enough buffer, which makes the whole API somewhat broken because it could be different size than @buflen but since trusted keys is the only module using this API right now I think that this fix is sufficient for the moment. In the near future the plan is to replace the parameters with a tpm_buf created by the caller. Reported-by: Mimi Zohar Suggested-by: Mimi Zohar Cc: stable@vger.kernel.org Fixes: 412eb585587a ("use tpm_buf in tpm_transmit_cmd() as the IO parameter") Signed-off-by: Jarkko Sakkinen Reviewed-by: Jerry Snitselaar Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm-interface.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -354,14 +354,9 @@ int tpm_send(struct tpm_chip *chip, void if (!chip) return -ENODEV; - rc = tpm_buf_init(&buf, 0, 0); - if (rc) - goto out; - - memcpy(buf.data, cmd, buflen); + buf.data = cmd; rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to a send a command"); - tpm_buf_destroy(&buf); -out: + tpm_put_ops(chip); return rc; }