public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: "Fortier,Vincent [Montreal]" <Vincent.Fortier1@EC.GC.CA>,
	Greg KH <gregkh@suse.de>, Randy Dunlap <randy.dunlap@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
	kay.sievers@vrfy.org, Balbir Singh <balbir@in.ibm.com>,
	maneesh@in.ibm.com
Subject: Re: 2.6.22.14 oops msg with commvault galaxy ?
Date: Thu, 13 Dec 2007 14:12:42 +0100	[thread overview]
Message-ID: <20071213131242.GD28340@elte.hu> (raw)
In-Reply-To: <20071213130231.GB16905@linux.vnet.ibm.com>


* Dhaval Giani <dhaval@linux.vnet.ibm.com> wrote:

> > >  static void user_attr_init(struct subsys_attribute *sa, char *name, int mode)
> > >  {
> > > +	sa->attr.owner = NULL;
> > >  	sa->attr.name = name;
> > 
> > i'm wondering why doesnt this affect 2.6.23 and later? Does sysfs 
> > initialize the owner field to NULL automatically?
> > 
> 
> Going through git log, it seems that commit 
> 7b595756ec1f49e0049a9e01a1298d53a7faaa15 deemed attribute->owner as 
> unnecessary. I guess that answers the question.

thx. The only open question seems to be: Vincent had sysfs crashes 
without the CFS patchset as well.

Wouldnt it be prudent to backport the core bits of the above commit 
(attached below), to make sure the owner field is never utilized. 
(because it seems it's so easy and common to not maintain it properly) 

Vincent, does the patch below resolve the non-CFS crashes?

	Ingo

diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 618b8ae..3c5574a 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -175,25 +175,20 @@ static int open(struct inode * inode, struct file * file)
 	if (!sysfs_get_active(attr_sd))
 		return -ENODEV;
 
-	/* Grab the module reference for this attribute */
-	error = -ENODEV;
-	if (!try_module_get(attr->attr.owner))
-		goto err_sput;
-
 	error = -EACCES;
 	if ((file->f_mode & FMODE_WRITE) && !(attr->write || attr->mmap))
-		goto err_mput;
+		goto err_out;
 	if ((file->f_mode & FMODE_READ) && !(attr->read || attr->mmap))
-		goto err_mput;
+		goto err_out;
 
 	error = -ENOMEM;
 	bb = kzalloc(sizeof(*bb), GFP_KERNEL);
 	if (!bb)
-		goto err_mput;
+		goto err_out;
 
 	bb->buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!bb->buffer)
-		goto err_mput;
+		goto err_out;
 
 	mutex_init(&bb->mutex);
 	file->private_data = bb;
@@ -203,9 +198,7 @@ static int open(struct inode * inode, struct file * file)
 	sysfs_get(attr_sd);
 	return 0;
 
- err_mput:
-	module_put(attr->attr.owner);
- err_sput:
+ err_out:
 	sysfs_put_active(attr_sd);
 	kfree(bb);
 	return error;
@@ -214,13 +207,11 @@ static int open(struct inode * inode, struct file * file)
 static int release(struct inode * inode, struct file * file)
 {
 	struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
-	struct bin_attribute *attr = attr_sd->s_elem.bin_attr.bin_attr;
 	struct bin_buffer *bb = file->private_data;
 
 	if (bb->mmapped)
 		sysfs_put_active_two(attr_sd);
 	sysfs_put(attr_sd);
-	module_put(attr->attr.owner);
 	kfree(bb->buffer);
 	kfree(bb);
 	return 0;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index d673d9b..a84b734 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -241,7 +241,6 @@ sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t
 static int sysfs_open_file(struct inode *inode, struct file *file)
 {
 	struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
-	struct attribute *attr = attr_sd->s_elem.attr.attr;
 	struct kobject *kobj = attr_sd->s_parent->s_elem.dir.kobj;
 	struct sysfs_buffer * buffer;
 	struct sysfs_ops * ops = NULL;
@@ -251,11 +250,6 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	if (!sysfs_get_active_two(attr_sd))
 		return -ENODEV;
 
-	/* Grab the module reference for this attribute */
-	error = -ENODEV;
-	if (!try_module_get(attr->owner))
-		goto err_sput;
-
 	/* if the kobject has no ktype, then we assume that it is a subsystem
 	 * itself, and use ops for it.
 	 */
@@ -272,7 +266,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	 * or the subsystem have no operations.
 	 */
 	if (!ops)
-		goto err_mput;
+		goto err_out;
 
 	/* File needs write support.
 	 * The inode's perms must say it's ok, 
@@ -280,7 +274,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	 */
 	if (file->f_mode & FMODE_WRITE) {
 		if (!(inode->i_mode & S_IWUGO) || !ops->store)
-			goto err_mput;
+			goto err_out;
 	}
 
 	/* File needs read support.
@@ -289,7 +283,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	 */
 	if (file->f_mode & FMODE_READ) {
 		if (!(inode->i_mode & S_IRUGO) || !ops->show)
-			goto err_mput;
+			goto err_out;
 	}
 
 	/* No error? Great, allocate a buffer for the file, and store it
@@ -298,7 +292,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	error = -ENOMEM;
 	buffer = kzalloc(sizeof(struct sysfs_buffer), GFP_KERNEL);
 	if (!buffer)
-		goto err_mput;
+		goto err_out;
 
 	init_MUTEX(&buffer->sem);
 	buffer->needs_read_fill = 1;
@@ -310,9 +304,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	sysfs_get(attr_sd);
 	return 0;
 
- err_mput:
-	module_put(attr->owner);
- err_sput:
+ err_out:
 	sysfs_put_active_two(attr_sd);
 	return error;
 }
@@ -320,12 +312,9 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 static int sysfs_release(struct inode * inode, struct file * filp)
 {
 	struct sysfs_dirent *attr_sd = filp->f_path.dentry->d_fsdata;
-	struct attribute *attr = attr_sd->s_elem.attr.attr;
 	struct sysfs_buffer *buffer = filp->private_data;
 
 	sysfs_put(attr_sd);
-	/* After this point, attr should not be accessed. */
-	module_put(attr->owner);
 
 	if (buffer) {
 		if (buffer->page)


  reply	other threads:[~2007-12-13 13:14 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-30 13:02 2.6.22.14 oops msg with commvault galaxy ? Vincent Fortier
2007-11-30 17:12 ` Randy Dunlap
2007-11-30 17:35   ` Fortier,Vincent [Montreal]
2007-12-04 13:47     ` Vincent Fortier
2007-12-07 22:15       ` Randy Dunlap
2007-12-07 23:11         ` Andrew Morton
2007-12-08  1:14           ` Randy Dunlap
2007-12-10 13:20             ` Fortier,Vincent [Montreal]
2007-12-10 14:03               ` Fortier,Vincent [Montreal]
2007-12-10 17:15                 ` Randy Dunlap
2007-12-10 17:55                   ` Fortier,Vincent [Montreal]
2007-12-11 14:54                   ` Dhaval Giani
2007-12-11 16:43                     ` Dhaval Giani
2007-12-11 17:04                       ` Greg KH
2007-12-11 17:23                         ` Dhaval Giani
2007-12-11 17:47                           ` Fortier,Vincent [Montreal]
2007-12-11 18:20                             ` Dhaval Giani
2007-12-11 18:25                               ` Dhaval Giani
2007-12-11 19:08                                 ` Fortier,Vincent [Montreal]
2007-12-11 19:12                                   ` Randy Dunlap
2007-12-11 21:06                                   ` Ingo Molnar
2007-12-12  7:08                                     ` Dhaval Giani
2007-12-12 12:57                                       ` Fortier,Vincent [Montreal]
2007-12-12 13:05                                         ` Fortier,Vincent [Montreal]
2007-12-12 13:41                                         ` Dhaval Giani
2007-12-12 18:45                                           ` Fortier,Vincent [Montreal]
2007-12-13 11:43                                             ` Dhaval Giani
2007-12-13 12:55                                               ` Ingo Molnar
2007-12-13 13:02                                                 ` Dhaval Giani
2007-12-13 13:12                                                   ` Ingo Molnar [this message]
2007-12-13 13:43                                                     ` Vincent Fortier
2007-12-13 13:24                                                   ` Vincent Fortier
2007-12-13 14:41                                                     ` Dhaval Giani
2007-12-13 13:59                                                 ` Kay Sievers
2007-12-13 15:02                                                   ` Vincent Fortier
2007-12-13 16:23                                                     ` Kay Sievers
2007-12-13 16:50                                                       ` Ingo Molnar
2007-12-13 17:10                                                         ` Kay Sievers
2007-12-13 20:21                                                           ` Ingo Molnar
2007-12-14  2:14                                                             ` Dhaval Giani
2007-12-14 16:26                                                             ` Greg KH
2007-12-14 17:07                                                               ` Dhaval Giani
2007-12-14 17:28                                                                 ` Greg KH
2007-12-20 13:49                                                                   ` Vincent Fortier
2007-12-13 17:20                                                         ` Dhaval Giani
2007-12-11 19:31                           ` Greg KH

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=20071213131242.GD28340@elte.hu \
    --to=mingo@elte.hu \
    --cc=Vincent.Fortier1@EC.GC.CA \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@in.ibm.com \
    --cc=dhaval@linux.vnet.ibm.com \
    --cc=gregkh@suse.de \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maneesh@in.ibm.com \
    --cc=randy.dunlap@oracle.com \
    --cc=vatsa@linux.vnet.ibm.com \
    /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