rt->ephemeral_copy = mfree(rt->ephemeral_copy);
}
-void exec_params_clear(ExecParameters *p) {
+void exec_params_shallow_clear(ExecParameters *p) {
if (!p)
return;
+ /* This is called on the PID1 side, as many of the struct's FDs are only borrowed, and actually
+ * owned by the manager or other objects, and reused across multiple units. */
+
p->environment = strv_free(p->environment);
p->fd_names = strv_free(p->fd_names);
p->files_env = strv_free(p->files_env);
p->confirm_spawn = mfree(p->confirm_spawn);
}
-void exec_params_serialized_done(ExecParameters *p) {
+void exec_params_deep_clear(ExecParameters *p) {
if (!p)
return;
+ /* This is called on the sd-executor side, where everything received is owned by the process and has
+ * to be fully cleaned up to make sanitizers and analyzers happy, as opposed as the shallow clean
+ * function above. */
+
close_many_unset(p->fds, p->n_socket_fds + p->n_storage_fds);
p->cgroup_path = mfree(p->cgroup_path);
p->fallback_smack_process_label = mfree(p->fallback_smack_process_label);
- exec_params_clear(p);
+ exec_params_shallow_clear(p);
}
void exec_directory_done(ExecDirectory *d) {
void exec_runtime_clear(ExecRuntime *rt);
int exec_params_get_cgroup_path(const ExecParameters *params, const CGroupContext *c, char **ret);
-void exec_params_clear(ExecParameters *p);
+void exec_params_shallow_clear(ExecParameters *p);
void exec_params_dump(const ExecParameters *p, FILE* f, const char *prefix);
-void exec_params_serialized_done(ExecParameters *p);
+void exec_params_deep_clear(ExecParameters *p);
bool exec_context_get_cpu_affinity_from_numa(const ExecContext *c);
_cleanup_(cgroup_context_done) CGroupContext cgroup_context = {};
_cleanup_(exec_context_done) ExecContext context = {};
_cleanup_(exec_command_done) ExecCommand command = {};
- _cleanup_(exec_params_serialized_done) ExecParameters params = EXEC_PARAMETERS_INIT(/* flags= */ 0);
+ _cleanup_(exec_params_deep_clear) ExecParameters params = EXEC_PARAMETERS_INIT(/* flags= */ 0);
_cleanup_(exec_shared_runtime_done) ExecSharedRuntime shared = {
.netns_storage_socket = EBADF_PAIR,
.ipcns_storage_socket = EBADF_PAIR,
#include "service.h"
static void exec_fuzz_one(FILE *f, FDSet *fdset) {
- _cleanup_(exec_params_serialized_done) ExecParameters params = {
- .stdin_fd = -EBADF,
- .stdout_fd = -EBADF,
- .stderr_fd = -EBADF,
- .exec_fd = -EBADF,
- .user_lookup_fd = -EBADF,
- .bpf_outer_map_fd = -EBADF,
- };
+ _cleanup_(exec_params_deep_clear) ExecParameters params = EXEC_PARAMETERS_INIT(/* flags= */ 0);
_cleanup_(exec_context_done) ExecContext exec_context = {};
_cleanup_(cgroup_context_done) CGroupContext cgroup_context = {};
DynamicCreds dynamic_creds = {};
static int mount_spawn(Mount *m, ExecCommand *c, PidRef *ret_pid) {
- _cleanup_(exec_params_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
+ _cleanup_(exec_params_shallow_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN);
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
pid_t pid;
ExecFlags flags,
PidRef *ret_pid) {
- _cleanup_(exec_params_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(flags);
+ _cleanup_(exec_params_shallow_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(flags);
_cleanup_(sd_event_source_unrefp) sd_event_source *exec_fd_source = NULL;
_cleanup_strv_free_ char **final_env = NULL, **our_env = NULL;
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
static int socket_spawn(Socket *s, ExecCommand *c, PidRef *ret_pid) {
- _cleanup_(exec_params_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
+ _cleanup_(exec_params_shallow_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN);
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
pid_t pid;
static int swap_spawn(Swap *s, ExecCommand *c, PidRef *ret_pid) {
- _cleanup_(exec_params_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
+ _cleanup_(exec_params_shallow_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN);
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
pid_t pid;