On 07/31, Oleg Nesterov wrote:So an example of what this would be used for (going into commit message of a v2 with your earlier suggestions):
> From: Zach Levis <zml@xxxxxxxxxxxxxxxxxx>
> Subject: fs/binfmts: better handling of binfmt loops
>
> With these changes, when a binfmt loop is encountered, the ELOOP will
> propagate back to the 0 depth. At this point the argv and argc values
> will be reset to what they were originally and an attempt is made to
> continue with the following binfmt handlers.
I must admit, I do not really understand why do we want to recover
after pr_err(). Perhaps the changelog could say a bit more.
And still can't. Probably I missed something, but it seems that
this tries to "fix" the wrong /proc/sys/fs/binfmt_misc/register...
> +
> + copy_strings(bprm->argc_orig, *((struct user_arg_ptr *) bprm->argv_orig), bprm);
Perhaps it would be more clean to add "struct user_arg_ptr;"
into binfmts.h and avoid the typecast.
I'm not sure if that's even necessary. It looks like there's copy_strings()->get_arg_page()->acct_arg_size() that's already called.
And I do not think we should ignore the possible error from
copy_strings(). Even if we know that it succeeded before, another
thread can, say, unmap this memory in between.
And since we do copy_strings() again we probably need acct_arg_size()
after remove_arg_zero() loop, although this is not that important.
And with this patch "depth == 0" check(s) look even worse, imho we
need to cleanup this code first. And proc_exec_connector() looks
simply wrong. I'll try to make a patch.
But once again, I can be easily wrong, so please correct me.
Oleg.