Skip to contentSkip to conversation

cgroup dentry insufficiently initialized prior to calling d_instantiate.

DISCUSSION Casey Schaufler 3 participants 3 messages May 10, 2013 – May 14, 2013 1 message not in the archive cgroup

lore
Share & tools
lore
#0 lore raw

In kernel/cgroup.c in cgroup_add_file() we have:

        dentry = lookup_one_len(name, dir, strlen(name));
        if (IS_ERR(dentry)) {
                error = PTR_ERR(dentry);
                goto out;
        }

        mode = cgroup_file_mode(cft);
        error = cgroup_create_file(dentry, mode | S_IFREG, cgrp->root->sb);
        if (!error) {
                cfe->type = (void *)cft;
                cfe->dentry = dentry;
                dentry->d_fsdata = cfe;
                simple_xattrs_init(&cfe->xattrs);
                list_add_tail(&cfe->node, &parent->files);
                cfe = NULL;
        }
        dput(dentry);

cgroup_create_file() calls d_instantiate, which may decide to look at the xattrs on the file. Smack always does this and SELinux can be configured to do so, although no one seems to be using that option. Since the dentry has not been initialized panics in __d_xattr ensue. See bugzilla 57791.

#1 lore raw
Quoted 22 lines · Casey Schaufler

In kernel/cgroup.c in cgroup_add_file() we have:

        dentry = lookup_one_len(name, dir, strlen(name));
        if (IS_ERR(dentry)) {
                error = PTR_ERR(dentry);
                goto out;
        }

        mode = cgroup_file_mode(cft);
        error = cgroup_create_file(dentry, mode | S_IFREG, cgrp->root->sb);
        if (!error) {
                cfe->type = (void *)cft;
                cfe->dentry = dentry;
                dentry->d_fsdata = cfe;
                simple_xattrs_init(&cfe->xattrs);
                list_add_tail(&cfe->node, &parent->files);
                cfe = NULL;
        }
        dput(dentry);
Quoted 7 lines

cgroup_create_file() calls d_instantiate, which may decide to look at the xattrs on the file. Smack always does this and SELinux can be configured to do so, although no one seems to be using that option. Since the dentry has not been initialized panics in __d_xattr ensue. See bugzilla 57791.

cgroup_add_file() should initialize xattrs before calling d_instantiate(), just like cgroup_create() does.

I'll prepare a patch to fix it. Thanks for the report!

#3 lore raw
In reply to a message not in the archive
Quoted 22 lines · Casey Schaufler

In kernel/cgroup.c in cgroup_add_file() we have:

        dentry = lookup_one_len(name, dir, strlen(name));
        if (IS_ERR(dentry)) {
                error = PTR_ERR(dentry);
                goto out;
        }

        mode = cgroup_file_mode(cft);
        error = cgroup_create_file(dentry, mode | S_IFREG, cgrp->root->sb);
        if (!error) {
                cfe->type = (void *)cft;
                cfe->dentry = dentry;
                dentry->d_fsdata = cfe;
                simple_xattrs_init(&cfe->xattrs);
                list_add_tail(&cfe->node, &parent->files);
                cfe = NULL;
        }
        dput(dentry);
Quoted 7 lines

cgroup_create_file() calls d_instantiate, which may decide to look at the xattrs on the file. Smack always does this and SELinux can be configured to do so, although no one seems to be using that option. Since the dentry has not been initialized panics in __d_xattr ensue. See bugzilla 57791.

cgroup_add_file() should initialize xattrs before calling d_instantiate(), just like cgroup_create() does.

I'll prepare a patch to fix it. Thanks for the report!