Lines Matching +full:wait +full:- +full:on +full:- +full:write
1 // SPDX-License-Identifier: GPL-2.0-only
3 * umh - the kernel usermode helper
42 if (info->cleanup) in call_usermodehelper_freeinfo()
43 (*info->cleanup)(info); in call_usermodehelper_freeinfo()
49 struct completion *comp = xchg(&sub_info->complete, NULL); in umh_complete()
70 spin_lock_irq(¤t->sighand->siglock); in call_usermodehelper_exec_async()
72 spin_unlock_irq(¤t->sighand->siglock); in call_usermodehelper_exec_async()
80 current->fs->umask = 0022; in call_usermodehelper_exec_async()
88 retval = -ENOMEM; in call_usermodehelper_exec_async()
94 new->cap_bset = cap_intersect(usermodehelper_bset, new->cap_bset); in call_usermodehelper_exec_async()
95 new->cap_inheritable = cap_intersect(usermodehelper_inheritable, in call_usermodehelper_exec_async()
96 new->cap_inheritable); in call_usermodehelper_exec_async()
99 if (sub_info->init) { in call_usermodehelper_exec_async()
100 retval = sub_info->init(sub_info, new); in call_usermodehelper_exec_async()
110 retval = kernel_execve(sub_info->path, in call_usermodehelper_exec_async()
111 (const char *const *)sub_info->argv, in call_usermodehelper_exec_async()
112 (const char *const *)sub_info->envp); in call_usermodehelper_exec_async()
114 sub_info->retval = retval; in call_usermodehelper_exec_async()
119 if (!(sub_info->wait & UMH_WAIT_PROC)) in call_usermodehelper_exec_async()
135 sub_info->retval = pid; in call_usermodehelper_exec_sync()
137 kernel_wait(pid, &sub_info->retval); in call_usermodehelper_exec_sync()
148 * possibly reduced affinity (eg: per-cpu workqueues). We don't want
151 * Unbound workqueues provide such wide affinity and allow to block on
163 if (sub_info->wait & UMH_WAIT_PROC) { in call_usermodehelper_exec_work()
169 * want to pollute current->children, and we need a parent in call_usermodehelper_exec_work()
170 * that always ignores SIGCHLD to ensure auto-reaping. in call_usermodehelper_exec_work()
175 sub_info->retval = pid; in call_usermodehelper_exec_work()
182 * If set, call_usermodehelper_exec() will exit immediately returning -EBUSY
184 * land has been frozen during a system-wide hibernation or suspend operation).
185 * Should always be manipulated under umhelper_sem acquired for write.
193 * Wait queue head used by usermodehelper_disable() to wait for all running
199 * Used by usermodehelper_read_lock_wait() to wait for usermodehelper_disabled
205 * Time to wait for running_helpers to become zero before the setting of
212 DEFINE_WAIT(wait); in usermodehelper_read_trylock()
217 prepare_to_wait(&usermodehelper_disabled_waitq, &wait, in usermodehelper_read_trylock()
223 ret = -EAGAIN; in usermodehelper_read_trylock()
235 finish_wait(&usermodehelper_disabled_waitq, &wait); in usermodehelper_read_trylock()
242 DEFINE_WAIT(wait); in usermodehelper_read_lock_wait()
245 return -EINVAL; in usermodehelper_read_lock_wait()
249 prepare_to_wait(&usermodehelper_disabled_waitq, &wait, in usermodehelper_read_lock_wait()
262 finish_wait(&usermodehelper_disabled_waitq, &wait); in usermodehelper_read_lock_wait()
274 * __usermodehelper_set_disable_depth - Modify usermodehelper_disabled.
289 * __usermodehelper_disable - Prevent new helpers from being started.
292 * Set usermodehelper_disabled to @depth and wait for running helpers to exit.
299 return -EINVAL; in __usermodehelper_disable()
306 * From now on call_usermodehelper_exec() won't start any new in __usermodehelper_disable()
318 return -EAGAIN; in __usermodehelper_disable()
334 * call_usermodehelper_setup - prepare to call a usermode helper
343 * Returns either %NULL on allocation failure, or a subprocess_info
348 * exec. A non-zero return code causes the process to error out, exit,
367 INIT_WORK(&sub_info->work, call_usermodehelper_exec_work); in call_usermodehelper_setup()
370 sub_info->path = CONFIG_STATIC_USERMODEHELPER_PATH; in call_usermodehelper_setup()
372 sub_info->path = path; in call_usermodehelper_setup()
374 sub_info->argv = argv; in call_usermodehelper_setup()
375 sub_info->envp = envp; in call_usermodehelper_setup()
377 sub_info->cleanup = cleanup; in call_usermodehelper_setup()
378 sub_info->init = init; in call_usermodehelper_setup()
379 sub_info->data = data; in call_usermodehelper_setup()
386 * call_usermodehelper_exec - start a usermode application
388 * @wait: wait for the application to finish and return status.
389 * when UMH_NO_WAIT don't wait at all, but you get no useful error back
393 * Runs a user-space application. The application is started
394 * asynchronously if wait is not set, and runs as a child of system workqueues.
398 * all. You can't rely on sub_info->{init,cleanup} being called even for
399 * UMH_WAIT_* wait modes as STATIC_USERMODEHELPER_PATH="" turns all helpers
400 * into a successful no-op.
402 int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) in call_usermodehelper_exec() argument
408 if (!sub_info->path) { in call_usermodehelper_exec()
410 return -EINVAL; in call_usermodehelper_exec()
414 retval = -EBUSY; in call_usermodehelper_exec()
423 if (strlen(sub_info->path) == 0) in call_usermodehelper_exec()
431 sub_info->complete = (wait == UMH_NO_WAIT) ? NULL : &done; in call_usermodehelper_exec()
432 sub_info->wait = wait; in call_usermodehelper_exec()
434 queue_work(system_unbound_wq, &sub_info->work); in call_usermodehelper_exec()
435 if (wait == UMH_NO_WAIT) /* task has freed sub_info */ in call_usermodehelper_exec()
438 if (wait & UMH_FREEZABLE) in call_usermodehelper_exec()
441 if (wait & UMH_KILLABLE) { in call_usermodehelper_exec()
447 if (xchg(&sub_info->complete, NULL)) in call_usermodehelper_exec()
451 * fallthrough; in case of -ERESTARTSYS now do uninterruptible in call_usermodehelper_exec()
461 retval = sub_info->retval; in call_usermodehelper_exec()
471 * call_usermodehelper() - prepare and start a usermode application
475 * @wait: wait for the application to finish and return status.
476 * when UMH_NO_WAIT don't wait at all, but you get no useful error back
483 int call_usermodehelper(const char *path, char **argv, char **envp, int wait) in call_usermodehelper() argument
486 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL; in call_usermodehelper()
491 return -ENOMEM; in call_usermodehelper()
493 return call_usermodehelper_exec(info, wait); in call_usermodehelper()
498 static int proc_cap_handler(struct ctl_table *table, int write, in proc_cap_handler() argument
506 if (write && (!capable(CAP_SETPCAP) || in proc_cap_handler()
508 return -EPERM; in proc_cap_handler()
514 * Legacy format: capabilities are exposed as two 32-bit values in proc_cap_handler()
516 cap = table->data; in proc_cap_handler()
518 cap_array[0] = (u32) cap->val; in proc_cap_handler()
519 cap_array[1] = cap->val >> 32; in proc_cap_handler()
526 * actually read or write and array of ulongs from userspace. Remember in proc_cap_handler()
529 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); in proc_cap_handler()
539 if (write) { in proc_cap_handler()