lkml.org 
[lkml]   [2020]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 3/4] kmod: Return directly if module name is empty in request_module()
On Mon, Apr 20, 2020 at 08:33:54PM +0800, Tiezhu Yang wrote:
> If module name is empty, it is better to return directly at the beginning
> of request_module() without doing the needless call_modprobe() operation.
>
> Call trace:
>
> request_module()
> |
> |
> __request_module()
> |
> |
> call_modprobe()
> |
> |
> call_usermodehelper_exec() -- retval = sub_info->retval;
> |
> |
> call_usermodehelper_exec_work()
> |
> |
> call_usermodehelper_exec_sync() -- sub_info->retval = ret;
> |
> | --> call_usermodehelper_exec_async() --> do_execve()
> |
> kernel_wait4(pid, (int __user *)&ret, 0, NULL);
>
> sub_info->retval is 256 after call kernel_wait4(), the function
> call_usermodehelper_exec() returns sub_info->retval which is 256,
> then call_modprobe() and __request_module() returns 256.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>

Thanks for looking into this. I still cannot find where
userspace it returns 256. Can you? If I run modprobe without
an argument I see 1 returned.

At least kmod [0] has a series of cmd helper structs, the one for modprobe
seems to be kmod_cmd_compat_modprobe, and I can see -1 returned which
can be converted to 255. It can also return EXIT_FAILURE or EXIT_SUCCESS
and /usr/include/stdlib.h defines these as 1 and 0 respectively.

https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/

Luis

\
 
 \ /
  Last update: 2020-04-20 20:20    [W:3.080 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site