1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2020 Google LLC.
9 #include <bpf/bpf_helpers.h>
10 #include <bpf/bpf_tracing.h>
12 char _license[] SEC("license") = "GPL";
15 __uint(type, BPF_MAP_TYPE_TASK_STORAGE);
16 __uint(map_flags, BPF_F_NO_PREALLOC);
19 } secure_exec_task_map SEC(".maps");
21 SEC("lsm/bprm_creds_for_exec")
22 int BPF_PROG(secure_exec, struct linux_binprm *bprm)
26 secureexec = bpf_task_storage_get(&secure_exec_task_map,
27 bpf_get_current_task_btf(), 0,
28 BPF_LOCAL_STORAGE_GET_F_CREATE);
30 if (secureexec && *secureexec)
31 bpf_bprm_opts_set(bprm, BPF_F_BPRM_SECUREEXEC);