From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031704AbdADSVJ (ORCPT ); Wed, 4 Jan 2017 13:21:09 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44174 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1761472AbdADSTp (ORCPT ); Wed, 4 Jan 2017 13:19:45 -0500 Subject: Re: [tpmdd-devel] [PATCH RFC 2/4] tpm: validate TPM 2.0 commands From: James Bottomley To: Stefan Berger , Jarkko Sakkinen Cc: linux-security-module@vger.kernel.org, tpmdd-devel@lists.sourceforge.net, open list Date: Wed, 04 Jan 2017 10:19:36 -0800 In-Reply-To: References: <20170102132213.22880-1-jarkko.sakkinen@linux.intel.com> <20170102132213.22880-3-jarkko.sakkinen@linux.intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17010418-0012-0000-0000-000012DFCB17 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006373; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000199; SDB=6.00803506; UDB=6.00390903; IPR=6.00581357; BA=6.00005030; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013823; XFM=3.00000011; UTC=2017-01-04 18:19:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17010418-0013-0000-0000-000049D89563 Message-Id: <1483553976.2561.38.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-04_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701040277 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-01-04 at 13:04 -0500, Stefan Berger wrote: > Jarkko Sakkinen wrote on 01/02/2017 > 08:22:08 AM: > > > --- a/drivers/char/tpm/tpm2-cmd.c > > +++ b/drivers/char/tpm/tpm2-cmd.c > > @@ -943,7 +943,9 @@ EXPORT_SYMBOL_GPL(tpm2_probe); > > */ > > int tpm2_auto_startup(struct tpm_chip *chip) > > { > > + u32 nr_commands; > > int rc; > > + int i; > > > > rc = tpm_get_timeouts(chip); > > if (rc) > > @@ -967,8 +969,49 @@ int tpm2_auto_startup(struct tpm_chip *chip) > > } > > } > > > > + rc = tpm2_get_tpm_pt(chip, TPM_PT_TOTAL_COMMANDS, &nr_commands, > NULL); > > + if (rc) > > + return rc; > > + > > + chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands, > > + GFP_KERNEL); > > For some reason this devm_kzalloc bombs for the vtpm proxy driver. > The only reason I could come up with is that it's being called before > tpm_add_char_device() has been called. No, it should be sufficient that chip->dev be initialized (which it is in tpm_chip_alloc()). What's the error you're getting? It does look like the intention was to have non-devm with tpm_chip_alloc() and devm with tpmm_chip_alloc(), but devm_kzalloc should just work regardless because it's tied to the device model. James