/* Ensure that all executions from hereon are * secure by setting a local storage which is read by * the bprm_creds_for_exec hook and sets bprm->secureexec.
*/
ret = update_storage(map_fd, secureexec); if (ret) exit(ret);
/* If the binary is executed with securexec=1, the dynamic * loader ignores and unsets certain variables like LD_PRELOAD, * TMPDIR etc. TMPDIR is used here to simplify the example, as * LD_PRELOAD requires a real .so file. * * If the value of TMPDIR is set, the bash command returns 10 * and if the value is unset, it returns 20.
*/
execle("/bin/bash", "bash", "-c", "[[ -z \"${TMPDIR}\" ]] || exit 10 && exit 20", NULL,
bash_envp); exit(errno);
} elseif (child_pid > 0) {
waitpid(child_pid, &child_status, 0);
ret = WEXITSTATUS(child_status);
/* If a secureexec occurred, the exit status should be 20 */ if (secureexec && ret == 20) return 0;
/* If normal execution happened, the exit code should be 10 */ if (!secureexec && ret == 10) return 0;
}
/* Run the test with the secureexec bit unset */
err = run_set_secureexec(bpf_map__fd(skel->maps.secure_exec_task_map),
0 /* secureexec */); if (CHECK(err, "run_set_secureexec:0", "err = %d\n", err)) goto close_prog;
/* Run the test with the secureexec bit set */
err = run_set_secureexec(bpf_map__fd(skel->maps.secure_exec_task_map),
1 /* secureexec */); if (CHECK(err, "run_set_secureexec:1", "err = %d\n", err)) goto close_prog;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.