[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC 4/4] {RFC} kmod.c: Add new call_usermodehelper_timeout()API



On 03/22, Boaz Harrosh wrote:
>
> On 03/22/2012 03:16 PM, Tetsuo Handa wrote:
>
> > I think you should use a fork()ed wrapper in userspace for implementing
> > timeout.
>
> I did that actually. But I would like not to be dependent on it. I would like
> the Kernel to be independent and simple timeout and recover,

Tetsuo, Boaz, since I do not understand the problem space, I am not
going to discuss the "do we need the timeout" thing.

But, just in case, perhaps there is no need to change kmod.c ? I do
not know if it works for you, but you can simply do something like


	struct kill_work {
		struct delayed_work work;
		struct pid *pid;
	};

	void kill_work_func(struct work_struct *_work)
	{
		struct kill_work *work = container_of(_work, struct kill_work, work);
		kill_pid(work->pid, SIGKILL);
		put_pid(work->pid);
		kfree(work);
	}

	int unh_setup_timeout(struct subprocess_info *info, struct cred *new)
	{
		struct kill_work *work = kmalloc(sizeof(struct kill_work));
		if (!work)
			return -ENOMEM;

		INIT_WORK(&work->work, kill_work_func);
		work->pid = get_pid(task_pid(current));
		schedule_delayed_work(&work->work, (long)info->data);

		return 0;
	}

Now you can do

	call_usermodehelper_fns(init => unh_setup_timeout,
				data => (void*)timeout);

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

Powered by Linux