From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970240AbdEYVQ0 (ORCPT ); Thu, 25 May 2017 17:16:26 -0400 Received: from quartz.orcorp.ca ([184.70.90.242]:36031 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966828AbdEYVQY (ORCPT ); Thu, 25 May 2017 17:16:24 -0400 Date: Thu, 25 May 2017 15:16:13 -0600 From: Jason Gunthorpe To: Jarkko Sakkinen Cc: tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, Peter Huewe , Marcel Selhorst , open list Subject: Re: [PATCH RFC] tpm: migrate pubek_show to struct tpm_buf Message-ID: <20170525211613.GA14802@obsidianresearch.com> References: <20170525211105.843-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170525211105.843-1-jarkko.sakkinen@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.156 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 25, 2017 at 02:11:04PM -0700, Jarkko Sakkinen wrote: > struct tpm_chip *chip = to_tpm_chip(dev); > + char anti_replay[20]; > > - tpm_cmd.header.in = tpm_readpubek_header; > - err = tpm_transmit_cmd(chip, NULL, &tpm_cmd, READ_PUBEK_RESULT_SIZE, > + rc = tpm_buf_init(&tpm_buf, TPM_TAG_RQU_COMMAND, TPM_ORD_READPUBEK); > + if (rc) > + return rc; > + > + /* The checksum is ignored so it doesn't matter what the contents are. > + */ > + tpm_buf_append(&tpm_buf, anti_replay, sizeof(anti_replay)); It does matter, we do not want to leak random kernel memory incase it has something sensitive. Zero anti_replay. > + > - /* > - ignore header 10 bytes > - algorithm 32 bits (1 == RSA ) > - encscheme 16 bits > - sigscheme 16 bits > - parameters (RSA 12->bytes: keybit, #primes, expbit) > - keylenbytes 32 bits > - 256 byte modulus > - ignore checksum 20 bytes > - */ Not sure we should delete the comment, tpm buf does not make the parse any clearer. Jason