Hi,

On Wed, 22 Jun 2005 23:15:56 -0700
Gerrit Huizenga <[EMAIL PROTECTED]> wrote:

> Index: linux-2.6.12-ckrm1/fs/rcfs/magic.c

> +static ssize_t
> +magic_write(struct file *file, const char __user *buf,
> +                        size_t count, loff_t *ppos)
> +{
> +     struct rcfs_inode_info *ri =
> +             rcfs_get_inode_info(file->f_dentry->d_parent->d_inode);

> +     done = magic_parse(ri->mfdentry->d_name.name,
> +                     optbuf, &resname, &otherstr);

I've got kernel oops (NULL pointer dereference) when writing 
"res=cpu,mode=enabled" to /rcfs/taskclass/config.  ri->mfdentry
has been NULL.
The 1st argument of magic_parse() should not be anything of 
the class directory but the name of the written file itself.

The following patch fixes the problem for me:

--- fs/rcfs/magic.c     2005/06/27 05:42:47     1.1
+++ fs/rcfs/magic.c     2005/06/27 07:23:57
@@ -181,23 +181,23 @@ magic_write(struct file *file, const cha
        }
        __copy_from_user(optbuf, buf, count);
        mkvalidstr(optbuf);
-       done = magic_parse(ri->mfdentry->d_name.name,
+       done = magic_parse(file->f_dentry->d_name.name,
                        optbuf, &resname, &otherstr);
        if (!done) {
                printk(KERN_ERR "Error parsing data written to %s\n",
-                               ri->mfdentry->d_name.name);
+                               file->f_dentry->d_name.name);
                goto out;
        }
-       if (!strcmp(ri->mfdentry->d_name.name, RCFS_CONFIG_NAME)) {
+       if (!strcmp(file->f_dentry->d_name.name, RCFS_CONFIG_NAME)) {
                func = core->classtype->set_config;
-       } else if (!strcmp(ri->mfdentry->d_name.name, RCFS_STATS_NAME)) {
+       } else if (!strcmp(file->f_dentry->d_name.name, RCFS_STATS_NAME)) {
                func = core->classtype->reset_stats;
        }
        if (func) {
                rc = func(core, resname, otherstr);
                if (rc) {
-                       printk(KERN_ERR "magic_write: %s: error\n",
-                               ri->mfdentry->d_name.name);
+                       printk(KERN_ERR "magic_write: %s: error %d\n",
+                               file->f_dentry->d_name.name, rc);
                }
        }
 out:


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
ckrm-tech mailing list
https://lists.sourceforge.net/lists/listinfo/ckrm-tech

Reply via email to