Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5759401ybe; Tue, 17 Sep 2019 13:03:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeav2q0b/iwmmxOdDaNx4b5GeFs/oVFM3Hd4hIJ2dDALcCAYrXr16yGhFYW+tLv8eWQV6x X-Received: by 2002:a50:d6db:: with SMTP id l27mr6742163edj.164.1568750597686; Tue, 17 Sep 2019 13:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568750597; cv=none; d=google.com; s=arc-20160816; b=Rwiez5hXAHL3fDfH56wmek7DUR97u6y5rZi83h/rIraxKR0YDmCfjQficxYb+QzXyl 09/n7V+0UusLeBJdjPsQpD2zCprwiEKS02u9r0lzTrtBndp6OJq/R7Hwbkm7r31Av9tN EO6gZVh7pt2lNPjBagp8PmbhUQmIcNeKojwalW9rA3dYldkUNgw4/OTSdqRj80gWU4v8 4PlQcObNhAWdjCN0ud+D1sZpJerXSxTAPfKixr0uPnSWJkZ9PtDuJz5yhh0iCkrdXISt OjXTG+s2KJ7s5vp+Y9ESQIyLkdIeWTck5b2PCw/Nlp+9KM74zaNfI+rjYUVrYt7tKX6X PqsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date; bh=m43ha01GHfxmLejRRAFKJ0r0Qd3J/x9bnPdjJwxWzPs=; b=SpiOI7uqKKxmQJ5GkAioKqxv+eIe5ybZv/+sIQ6yUyyUxivHuc/2m405V3HSKGNrfX F8Nlwf7JbWcM1pwaL/uyh941WhuLPeQ7mi4ZPUMXVPelhpXOV5h/kh/umqs+0cKrS4f3 gvi27xA5kRGvZSW4lgmG2p7oEqMo2oDG950t4y2+LMWySsBZrrGNaNxLW+byhVF1b5CH hsmH3jzWfU0bf6w+mYTzYgM7Tr4GudOtn0RdY33eaOAujkogVk3RxFW/9/QykNAuqKae pdUiorR1L9m8z9p0uUrnMV+D8I/boHjwCxu+BiNXuMJFqvB2K1yfxnN2uLCrK+fIQCoU 3bmw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bt13si1908242edb.245.2019.09.17.13.02.53; Tue, 17 Sep 2019 13:03:17 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729963AbfIQTNO (ORCPT + 99 others); Tue, 17 Sep 2019 15:13:14 -0400 Received: from mga09.intel.com ([134.134.136.24]:31049 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726523AbfIQTNO (ORCPT ); Tue, 17 Sep 2019 15:13:14 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2019 12:13:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="198791424" Received: from vcazacux-wtg.ger.corp.intel.com (HELO localhost) ([10.252.38.72]) by orsmga002.jf.intel.com with ESMTP; 17 Sep 2019 12:13:09 -0700 Date: Tue, 17 Sep 2019 22:13:07 +0300 From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org, Mimi Zohar , stable@vger.kernel.org, Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , open list Subject: Re: [PATCH] tpm: Wrap the buffer from the caller to tpm_buf in tpm_send() Message-ID: <20190917191307.GH10244@linux.intel.com> References: <20190916085008.22239-1-jarkko.sakkinen@linux.intel.com> <20190916210331.l6enypnafk2cwako@cantor> <20190916210454.mq3g2m6s5a2syaxp@cantor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190916210454.mq3g2m6s5a2syaxp@cantor> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 16, 2019 at 02:04:54PM -0700, Jerry Snitselaar wrote: > On Mon Sep 16 19, Jerry Snitselaar wrote: > > On Mon Sep 16 19, Jarkko Sakkinen wrote: > > > 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 > > > --- > > > drivers/char/tpm/tpm-interface.c | 8 ++------ > > > 1 file changed, 2 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c > > > index d9ace5480665..2459d36dd8cc 100644 > > > --- a/drivers/char/tpm/tpm-interface.c > > > +++ b/drivers/char/tpm/tpm-interface.c > > > @@ -358,13 +358,9 @@ int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen) > > > 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; > > > -- > > > 2.20.1 > > > > > > > Nothing uses the out label any longer so it should be dropped as well, but other than that... > > > > Acked-by: Jerry Snitselaar > > sigh (wrong emacs macro hit), that should be: > > Reviewed-by: Jerry Snitselaar Thank you! I pushed the commit to master/next. /Jarkko