mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: Kylene Hall <kjhall@us.ibm.com>
Cc: Greg KH <greg@kroah.com>,
	linux-kernel@vger.kernel.org, Emily Ratliff <emilyr@us.ibm.com>,
	Tom Lendacky <toml@us.ibm.com>,
	tpmdd-devel@lists.sourceforge.net
Subject: Re: [tpmdd-devel] Re: [PATCH 1/1] tpm: update tpm sysfs file ownership - updated version
Date: Wed, 9 Feb 2005 14:04:40 -0800	[thread overview]
Message-ID: <20050209140440.J469@build.pdx.osdl.net> (raw)
In-Reply-To: <Pine.LNX.4.58.0502091431160.4398@jo.austin.ibm.com>; from kjhall@us.ibm.com on Wed, Feb 09, 2005 at 02:35:34PM -0600

* Kylene Hall (kjhall@us.ibm.com) wrote:
> diff -uprN linux-2.6.10/drivers/char/tpm/tpm_atmel.c linux-2.6.10-tpm/drivers/char/tpm/tpm_atmel.c
> --- linux-2.6.10/drivers/char/tpm/tpm_atmel.c	2005-02-04 15:03:03.000000000 -0600
> +++ linux-2.6.10-tpm/drivers/char/tpm/tpm_atmel.c	2005-02-09 14:12:30.711621784 -0600
> @@ -131,6 +131,7 @@ static struct tpm_vendor_specific tpm_at
>  	.req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL,
>  	.req_complete_val = ATML_STATUS_DATA_AVAIL,
>  	.base = TPM_ATML_BASE,
> +	.attr = TPM_DEVICE_ATTRS,
>  	.miscdev.fops = &atmel_ops,
>  };
>  
> diff -uprN linux-2.6.10/drivers/char/tpm/tpm.c linux-2.6.10-tpm/drivers/char/tpm/tpm.c
> --- linux-2.6.10/drivers/char/tpm/tpm.c	2005-02-04 15:03:03.000000000 -0600
> +++ linux-2.6.10-tpm/drivers/char/tpm/tpm.c	2005-02-09 14:12:30.695624216 -0600
> @@ -213,7 +213,7 @@ static u8 pcrread[] = {
>  	0, 0, 0, 0		/* PCR index */
>  };
>  
> -static ssize_t show_pcrs(struct device *dev, char *buf)
> +ssize_t show_pcrs(struct device *dev, char *buf)

This is too generic a name for global namespace.

>  {
>  	u8 data[READ_PCR_RESULT_SIZE];
>  	ssize_t len;
> @@ -245,8 +245,7 @@ static ssize_t show_pcrs(struct device *
>  	}
>  	return str - buf;
>  }
> -
> -static DEVICE_ATTR(pcrs, S_IRUGO, show_pcrs, NULL);
> +EXPORT_SYMBOL_GPL(show_pcrs);
>  
>  #define  READ_PUBEK_RESULT_SIZE 314
>  static u8 readpubek[] = {
> @@ -255,7 +254,7 @@ static u8 readpubek[] = {
>  	0, 0, 0, 124,		/* TPM_ORD_ReadPubek */
>  };
>  
> -static ssize_t show_pubek(struct device *dev, char *buf)
> +ssize_t show_pubek(struct device *dev, char *buf)

same here

>  {
>  	u8 data[READ_PUBEK_RESULT_SIZE];
>  	ssize_t len;
> @@ -308,7 +307,7 @@ static ssize_t show_pubek(struct device 
>  	return str - buf;
>  }
>  
> -static DEVICE_ATTR(pubek, S_IRUGO, show_pubek, NULL);
> +EXPORT_SYMBOL_GPL(show_pubek);
>  
>  #define CAP_VER_RESULT_SIZE 18
>  static u8 cap_version[] = {
> @@ -329,7 +328,7 @@ static u8 cap_manufacturer[] = {
>  	0, 0, 1, 3
>  };
>  
> -static ssize_t show_caps(struct device *dev, char *buf)
> +ssize_t show_caps(struct device *dev, char *buf)

and here.

>  {
>  	u8 data[READ_PUBEK_RESULT_SIZE];
>  	ssize_t len;
> @@ -362,7 +361,26 @@ static ssize_t show_caps(struct device *
>  	return str - buf;
>  }
>  
> -static DEVICE_ATTR(caps, S_IRUGO, show_caps, NULL);
> +EXPORT_SYMBOL_GPL(show_caps);
> +
> +ssize_t store_cancel(struct device *dev, const char *buf,
> +			    size_t count)

and here

> +{
> +	struct tpm_chip *chip = dev_get_drvdata(dev);
> +	if (chip == NULL)
> +		return 0;
> +

Do you want any extra protection besides mode bits (S_IWUSR | S_IWGRP)?
How privileged should this operation be?

> +	chip->vendor->cancel(chip);
> +
> +	down(&chip->timer_manipulation_mutex);
> +	if (timer_pending(&chip->device_timer))
> +		mod_timer(&chip->device_timer, jiffies);
> +	up(&chip->timer_manipulation_mutex);
> +
> +	return count;
> +}
> +
> +EXPORT_SYMBOL_GPL(store_cancel);
>  
>  /*
>   * Device file system interface to the TPM
> @@ -524,6 +542,7 @@ EXPORT_SYMBOL_GPL(tpm_read);
>  void tpm_remove_hardware(struct device *dev)
>  {
>  	struct tpm_chip *chip = dev_get_drvdata(dev);
> +	int i;
>  
>  	if (chip == NULL) {
>  		dev_err(dev, "No device data found\n");
> @@ -539,9 +558,8 @@ void tpm_remove_hardware(struct device *
>  	dev_set_drvdata(dev, NULL);
>  	misc_deregister(&chip->vendor->miscdev);
>  
> -	device_remove_file(dev, &dev_attr_pubek);
> -	device_remove_file(dev, &dev_attr_pcrs);
> -	device_remove_file(dev, &dev_attr_caps);
> +	for ( i = 0; i < TPM_NUM_ATTR; i++ ) 
> +		device_remove_file(dev, &chip->vendor->attr[i]);
>  
>  	dev_mask[chip->dev_num / 32] &= !(1 << (chip->dev_num % 32));
>  
> @@ -663,10 +681,9 @@ dev_num_search_complete:
>  
>  	list_add(&chip->list, &tpm_chip_list);
>  
> -	device_create_file(dev, &dev_attr_pubek);
> -	device_create_file(dev, &dev_attr_pcrs);
> -	device_create_file(dev, &dev_attr_caps);
> -
> +	for ( i = 0; i < TPM_NUM_ATTR; i++ ) 
> +		device_create_file(dev, &chip->vendor->attr[i]);		
> +		
>  	return 0;
>  }
>  
> diff -uprN linux-2.6.10/drivers/char/tpm/tpm.h linux-2.6.10-tpm/drivers/char/tpm/tpm.h
> --- linux-2.6.10/drivers/char/tpm/tpm.h	2005-02-04 15:03:03.000000000 -0600
> +++ linux-2.6.10-tpm/drivers/char/tpm/tpm.h	2005-02-09 14:12:30.702623152 -0600
> @@ -25,11 +25,23 @@
>  #include <linux/miscdevice.h>
>  
>  #define TPM_TIMEOUT msecs_to_jiffies(5)
> +#define TPM_NUM_ATTR 4
>  
>  /* TPM addresses */
>  #define	TPM_ADDR			0x4E
>  #define	TPM_DATA			0x4F
>  
> +extern ssize_t show_pubek(struct device *, char *);
> +extern ssize_t show_pcrs(struct device *, char *);
> +extern ssize_t show_caps(struct device *, char *);
> +extern ssize_t store_cancel(struct device *, const char *, size_t);
> +
> +#define TPM_DEVICE_ATTRS { \
> +	__ATTR(pubek, S_IRUGO, show_pubek, NULL), \
> +	__ATTR(pcrs, S_IRUGO, show_pcrs, NULL), \
> +	__ATTR(caps, S_IRUGO, show_caps, NULL), \
> +	__ATTR(cancel, S_IWUSR | S_IWGRP, NULL, store_cancel) }

This doesn't look like the right way to go.  

> +
>  struct tpm_chip;
>  
>  struct tpm_vendor_specific {
> @@ -42,6 +54,7 @@ struct tpm_vendor_specific {
>  	void (*cancel) (struct tpm_chip *);
>  	u8 (*status) (struct tpm_chip *);
>  	struct miscdevice miscdev;
> +	struct device_attribute attr[TPM_NUM_ATTR];

So every device will have the same attrs?  If so, make that whole struct
exported (not the individual show/store methods) and reference that in
each driver.

thanks,
-chris
-- 
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net

  reply	other threads:[~2005-02-09 22:05 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-09 15:25 [PATCH 1/1] driver: Tpm hardware enablement Kylene Hall
2004-12-09 15:48 ` Arjan van de Ven
2004-12-09 17:06   ` Kylie Hall
2004-12-11  8:31     ` Nish Aravamudan
2004-12-10 20:45   ` Alan Cox
2004-12-10 10:56 ` Ian Campbell
2004-12-10 15:28   ` Kylene Hall
2004-12-10 15:41     ` Ian Campbell
2004-12-10 18:39       ` [tpmdd-devel] " Kylene Hall
2004-12-14  9:59         ` Ian Campbell
2004-12-16 22:37 ` [PATCH 1/1] driver: Tpm hardware enablement --updated version Kylene Hall
2004-12-16 22:48   ` Greg KH
2004-12-17 22:47     ` [tpmdd-devel] " Kylene Hall
2004-12-17  0:53   ` Chris Wright
2004-12-17 22:47     ` [tpmdd-devel] " Kylene Hall
2004-12-17 22:47   ` Kylene Hall
2004-12-17 22:59     ` Greg KH
2004-12-20 17:50     ` Kylene Hall
2004-12-21 16:51       ` Nish Aravamudan
2004-12-21 18:19         ` Kylene Hall
2005-01-12 18:45           ` Kylene Hall
2005-01-12 23:28             ` Greg KH
2005-01-18 22:29             ` [PATCH 1/1] tpm: fix cause of SMP stack traces Kylene Hall
2005-01-18 22:37               ` Chris Wright
2005-01-18 22:44                 ` Kylene Hall
2005-01-18 22:47                   ` Chris Wright
2005-01-18 22:47               ` Greg KH
2005-01-18 23:07                 ` Kylene Hall
2005-01-18 23:39               ` [PATCH 1/1] tpm: fix cause of SMP stack traces -- updated version Kylene Hall
2005-01-28 21:45                 ` [PATCH 1/1] tpm: insert missing up mutex in an error path Kylene Hall
2005-01-31 19:27                   ` [PATCH 1/1] tpm: insert missing up mutex in an error path, typo build fix -- updated version Kylene Hall
2005-02-03 16:40                     ` [PATCH 1/1] tpm: remove pci specific stuff from the underlying generic driver Kylene Hall
2005-02-04 20:12                       ` [PATCH 1/1] tpm: implement use of sysfs classes Kylene Hall
2005-02-04 20:52                         ` Greg KH
2005-02-04 21:37                           ` Kylene Hall
2005-02-04 21:51                             ` Greg KH
2005-02-09 18:05                               ` [PATCH 1/1] tpm: update tpm sysfs file ownership Kylene Hall
2005-02-09 18:17                                 ` Greg KH
2005-02-09 20:35                                   ` [tpmdd-devel] Re: [PATCH 1/1] tpm: update tpm sysfs file ownership - updated version Kylene Hall
2005-02-09 22:04                                     ` Chris Wright [this message]
2005-02-10 15:40                                       ` Kylene Hall
2005-02-01  8:28                 ` [PATCH 1/1] tpm: fix cause of SMP stack traces -- " Greg KH
2004-12-19 19:48   ` [PATCH 1/1] driver: Tpm hardware enablement --updated version Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050209140440.J469@build.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=emilyr@us.ibm.com \
    --cc=greg@kroah.com \
    --cc=kjhall@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=toml@us.ibm.com \
    --cc=tpmdd-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome