Lines Matching +full:wait +full:- +full:free +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0-only
3 * umh - the kernel usermode helper
41 if (info->cleanup) in call_usermodehelper_freeinfo()
42 (*info->cleanup)(info); in call_usermodehelper_freeinfo()
48 struct completion *comp = xchg(&sub_info->complete, NULL); in umh_complete()
69 spin_lock_irq(&current->sighand->siglock); in call_usermodehelper_exec_async()
71 spin_unlock_irq(&current->sighand->siglock); in call_usermodehelper_exec_async()
79 current->fs->umask = 0022; in call_usermodehelper_exec_async()
87 retval = -ENOMEM; in call_usermodehelper_exec_async()
93 new->cap_bset = cap_intersect(usermodehelper_bset, new->cap_bset); in call_usermodehelper_exec_async()
94 new->cap_inheritable = cap_intersect(usermodehelper_inheritable, in call_usermodehelper_exec_async()
95 new->cap_inheritable); in call_usermodehelper_exec_async()
98 if (sub_info->init) { in call_usermodehelper_exec_async()
99 retval = sub_info->init(sub_info, new); in call_usermodehelper_exec_async()
109 retval = kernel_execve(sub_info->path, in call_usermodehelper_exec_async()
110 (const char *const *)sub_info->argv, in call_usermodehelper_exec_async()
111 (const char *const *)sub_info->envp); in call_usermodehelper_exec_async()
113 sub_info->retval = retval; in call_usermodehelper_exec_async()
118 if (!(sub_info->wait & UMH_WAIT_PROC)) in call_usermodehelper_exec_async()
134 sub_info->retval = pid; in call_usermodehelper_exec_sync()
136 kernel_wait(pid, &sub_info->retval); in call_usermodehelper_exec_sync()
147 * possibly reduced affinity (eg: per-cpu workqueues). We don't want
162 if (sub_info->wait & UMH_WAIT_PROC) { in call_usermodehelper_exec_work()
168 * want to pollute current->children, and we need a parent in call_usermodehelper_exec_work()
169 * that always ignores SIGCHLD to ensure auto-reaping. in call_usermodehelper_exec_work()
174 sub_info->retval = pid; in call_usermodehelper_exec_work()
181 * If set, call_usermodehelper_exec() will exit immediately returning -EBUSY
183 * land has been frozen during a system-wide hibernation or suspend operation).
192 * Wait queue head used by usermodehelper_disable() to wait for all running
198 * Used by usermodehelper_read_lock_wait() to wait for usermodehelper_disabled
204 * Time to wait for running_helpers to become zero before the setting of
211 DEFINE_WAIT(wait); in usermodehelper_read_trylock()
216 prepare_to_wait(&usermodehelper_disabled_waitq, &wait, in usermodehelper_read_trylock()
222 ret = -EAGAIN; in usermodehelper_read_trylock()
234 finish_wait(&usermodehelper_disabled_waitq, &wait); in usermodehelper_read_trylock()
241 DEFINE_WAIT(wait); in usermodehelper_read_lock_wait()
244 return -EINVAL; in usermodehelper_read_lock_wait()
248 prepare_to_wait(&usermodehelper_disabled_waitq, &wait, in usermodehelper_read_lock_wait()
261 finish_wait(&usermodehelper_disabled_waitq, &wait); in usermodehelper_read_lock_wait()
273 * __usermodehelper_set_disable_depth - Modify usermodehelper_disabled.
288 * __usermodehelper_disable - Prevent new helpers from being started.
291 * Set usermodehelper_disabled to @depth and wait for running helpers to exit.
298 return -EINVAL; in __usermodehelper_disable()
317 return -EAGAIN; in __usermodehelper_disable()
333 * call_usermodehelper_setup - prepare to call a usermode helper
344 * exec the process and free the structure.
347 * exec. A non-zero return code causes the process to error out, exit,
366 INIT_WORK(&sub_info->work, call_usermodehelper_exec_work); in call_usermodehelper_setup()
369 sub_info->path = CONFIG_STATIC_USERMODEHELPER_PATH; in call_usermodehelper_setup()
371 sub_info->path = path; in call_usermodehelper_setup()
373 sub_info->argv = argv; in call_usermodehelper_setup()
374 sub_info->envp = envp; in call_usermodehelper_setup()
376 sub_info->cleanup = cleanup; in call_usermodehelper_setup()
377 sub_info->init = init; in call_usermodehelper_setup()
378 sub_info->data = data; in call_usermodehelper_setup()
385 * call_usermodehelper_exec - start a usermode application
387 * @wait: wait for the application to finish and return status.
388 * when UMH_NO_WAIT don't wait at all, but you get no useful error back
392 * Runs a user-space application. The application is started
393 * asynchronously if wait is not set, and runs as a child of system workqueues.
397 * all. You can't rely on sub_info->{init,cleanup} being called even for
398 * UMH_WAIT_* wait modes as STATIC_USERMODEHELPER_PATH="" turns all helpers
399 * into a successful no-op.
401 int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) in call_usermodehelper_exec() argument
407 if (!sub_info->path) { in call_usermodehelper_exec()
409 return -EINVAL; in call_usermodehelper_exec()
413 retval = -EBUSY; in call_usermodehelper_exec()
418 * If there is no binary for us to call, then just return and get out of in call_usermodehelper_exec()
419 * here. This allows us to set STATIC_USERMODEHELPER_PATH to "" and in call_usermodehelper_exec()
422 if (strlen(sub_info->path) == 0) in call_usermodehelper_exec()
427 * This makes it possible to use umh_complete to free in call_usermodehelper_exec()
430 sub_info->complete = (wait == UMH_NO_WAIT) ? NULL : &done; in call_usermodehelper_exec()
431 sub_info->wait = wait; in call_usermodehelper_exec()
433 queue_work(system_unbound_wq, &sub_info->work); in call_usermodehelper_exec()
434 if (wait == UMH_NO_WAIT) /* task has freed sub_info */ in call_usermodehelper_exec()
437 if (wait & UMH_FREEZABLE) in call_usermodehelper_exec()
440 if (wait & UMH_KILLABLE) { in call_usermodehelper_exec()
445 /* umh_complete() will see NULL and free sub_info */ in call_usermodehelper_exec()
446 if (xchg(&sub_info->complete, NULL)) in call_usermodehelper_exec()
450 * fallthrough; in case of -ERESTARTSYS now do uninterruptible in call_usermodehelper_exec()
460 retval = sub_info->retval; in call_usermodehelper_exec()
470 * call_usermodehelper() - prepare and start a usermode application
474 * @wait: wait for the application to finish and return status.
475 * when UMH_NO_WAIT don't wait at all, but you get no useful error back
482 int call_usermodehelper(const char *path, char **argv, char **envp, int wait) in call_usermodehelper() argument
485 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL; in call_usermodehelper()
490 return -ENOMEM; in call_usermodehelper()
492 return call_usermodehelper_exec(info, wait); in call_usermodehelper()
507 return -EPERM; in proc_cap_handler()
513 * Legacy format: capabilities are exposed as two 32-bit values in proc_cap_handler()
515 cap = table->data; in proc_cap_handler()
517 cap_array[0] = (u32) cap->val; in proc_cap_handler()
518 cap_array[1] = cap->val >> 32; in proc_cap_handler()