lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1228429874.19683.73.camel@blackbox>
Date:	Thu, 04 Dec 2008 20:31:14 -0200
From:	Rajiv Andrade <srajiv@...ux.vnet.ibm.com>
To:	Dave Hansen <dave@...ux.vnet.ibm.com>
Cc:	Mimi Zohar <zohar@...ux.vnet.ibm.com>,
	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	James Morris <jmorris@...ei.org>,
	Christoph Hellwig <hch@...radead.org>,
	Al Viro <viro@...IV.linux.org.uk>,
	David Safford <safford@...son.ibm.com>,
	Serge Hallyn <serue@...ux.vnet.ibm.com>,
	Rajiv Andrade <srajiv@...ibm.com>
Subject: Re: [PATCH 1/6] integrity: TPM internel kernel interface

> > > +
> > > +/**
> > > + * tpm_pcr_read - read a pcr value
> > > + * @chip_id: 	tpm chip identifier
> > > + * 		Upper 2 bytes: ANY, HW_ONLY or SW_ONLY
> > > + * 		Lower 2 bytes: tpm idx # or AN&
> > > + * @pcr_idx:	pcr idx to retrieve
> > > + * @res_buf: 	TPM_PCR value
> > > + * 		size of res_buf is 20 bytes (or NULL if you don't care)
> > > + *
> > > + * The TPM driver should be built-in, but for whatever reason it
> > > + * isn't, protect against the chip disappearing, by incrementing
> > > + * the module usage count.
> > > + */
> > > +int tpm_pcr_read(u32 chip_id, int pcr_idx, u8 *res_buf)
> > > +{
> > > +	u8 data[READ_PCR_RESULT_SIZE];
> > > +	int rc;
> > > +	__be32 index;
> > > +	int chip_num = chip_id & TPM_CHIP_NUM_MASK;
> > > +	struct tpm_chip *chip;
> > > +
> > > +	rcu_read_lock();
> > > +	chip = tpm_chip_lookup(chip_num, chip_id >> TPM_CHIP_TYPE_SHIFT);
> > > +	if (chip == NULL) {
> > > +		rcu_read_unlock();
> > > +		return -ENODEV;
> > > +	}
> > > +	if (!try_module_get(chip->dev->driver->owner)) {
> > > +		rcu_read_unlock();
> > > +		return -ENODEV;
> > > +	}
> > > +	rcu_read_unlock();
> > 
> > This little bit of lookup, check for NULL, and try_module_get() looks
> > cut-n-pasted in the next two functions.  Should be consolidated.
> > 
> 
> Same here.
> 
> > Also, if you need to shift down the chip_id every time anyway, why not
> > just do it inside the lookup function?
> 
> tpm_chip_lookup() only needs the chip type, not the entire chip_id, so
> its usage is probably clearer if written this way.
> 

Wait.. chip_num, the other parameter, depends on chip_id and a
previously defined constant, so, you are right, it's saner to just pass
chip_id to it.. sorry, and thanks. This will be included also on the
next patchset I'm about to send.

Rajiv

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ