svn commit: r367439 - head/sys/kern
Kyle Evans
kevans at FreeBSD.org
Sat Nov 7 03:28:33 UTC 2020
Author: kevans
Date: Sat Nov 7 03:28:32 2020
New Revision: 367439
URL: https://svnweb.freebsd.org/changeset/base/367439
Log:
imgact_binmisc: minor re-organization of imgact_binmisc_exec exits
Notably, streamline error paths through the existing 'done' label, making it
easier to quickly verify correct cleanup.
Future work might add a kernel-only flag to indicate that a interpreter uses
#a. Currently, all executions via imgact_binmisc pay the penalty of
constructing sname/fname, even if they will not use it. qemu-user-static
doesn't need it, the stock rc script for qemu-user-static certainly doesn't
use it, and I suspect these are the vast majority of (if not the only)
current users.
MFC after: 1 week
Modified:
head/sys/kern/imgact_binmisc.c
Modified: head/sys/kern/imgact_binmisc.c
==============================================================================
--- head/sys/kern/imgact_binmisc.c Sat Nov 7 01:32:16 2020 (r367438)
+++ head/sys/kern/imgact_binmisc.c Sat Nov 7 03:28:32 2020 (r367439)
@@ -580,24 +580,24 @@ imgact_binmisc_exec(struct image_params *imgp)
struct sbuf *sname;
char *s, *d;
+ sname = NULL;
/* Do we have an interpreter for the given image header? */
sx_slock(&interp_list_sx);
if ((ibe = imgact_binmisc_find_interpreter(image_header)) == NULL) {
- sx_sunlock(&interp_list_sx);
- return (-1);
+ error = -1;
+ goto done;
}
/* No interpreter nesting allowed. */
if (imgp->interpreted & IMGACT_BINMISC) {
- sx_sunlock(&interp_list_sx);
- return (ENOEXEC);
+ error = ENOEXEC;
+ goto done;
}
imgp->interpreted |= IMGACT_BINMISC;
if (imgp->args->fname != NULL) {
fname = imgp->args->fname;
- sname = NULL;
} else {
/* Use the fdescfs(5) path for fexecve(2). */
sname = sbuf_new_auto();
@@ -636,7 +636,6 @@ imgact_binmisc_exec(struct image_params *imgp)
default:
/* Hmm... This shouldn't happen. */
- sx_sunlock(&interp_list_sx);
printf("%s: Unknown macro #%c sequence in "
"interpreter string\n", KMOD_NAME, *(s + 1));
error = EINVAL;
@@ -648,7 +647,6 @@ imgact_binmisc_exec(struct image_params *imgp)
/* Make room for the interpreter */
error = exec_args_adjust_args(imgp->args, 0, offset);
if (error != 0) {
- sx_sunlock(&interp_list_sx);
goto done;
}
@@ -698,11 +696,11 @@ imgact_binmisc_exec(struct image_params *imgp)
s++;
}
*d = '\0';
- sx_sunlock(&interp_list_sx);
imgp->interpreter_name = imgp->args->begin_argv;
done:
+ sx_sunlock(&interp_list_sx);
if (sname)
sbuf_delete(sname);
return (error);
More information about the svn-src-all
mailing list