Skip to contentSkip to conversation

broken daemonize (COW credentials?)

DISCUSSION Jiri Slaby 2 participants 2 messages Jan 7, 2009 – Jan 8, 2009

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

Hi,

I'm observing daemonize crashes with this code:
static struct pid *pid;
static DECLARE_COMPLETION(comp);

static int bubak(void *data)

{
        daemonize("bubak");
        while (!signal_pending(current))
                msleep_interruptible(5000);
        complete_and_exit(&comp, 0);
        return 0;
}

static int init1(void) <-- module_init function

{
        int ret;

        ret = kernel_thread(bubak, NULL, 0);
        if (ret < 0)
                return ret;
        pid = find_get_pid(ret);
	return 0;
}

----------------------- cut here -------------------

This is due to:
daemonize
-> exit_mm
-> tsk->mm = NULL; (i.e. current->mm)
-> reparent_to_kthreadd
-> commit_creds

     -> set_dumpable(task->mm, suid_dumpable); (i.e. current->mm)

The culprit is probably COW credentials. David?

#1 lore raw
Quoted 1 line · Jiri Slaby

I'm observing daemonize crashes with this code:

I'm not seeing daemonize() crash, but I can see how it might - depending on the changes to the creds made by daemonize(). commit_creds() should only call set_dumpable() if task->mm is not NULL.

David