if (bpf_task_storage_delete(&task_storage_map, task)) return 0;
/* Ensure that the task_storage_map is disconnected from the storage. * The storage memory should not be freed back to the * bpf_mem_alloc.
*/
local_storage = task->bpf_storage; if (!local_storage || local_storage->smap) return 0;
/* new_dentry->d_inode can be NULL when the inode is renamed to a file * that did not exist before. The helper should be able to handle this * NULL pointer.
*/
bpf_inode_storage_get(&inode_storage_map, new_dentry->d_inode, 0,
BPF_LOCAL_STORAGE_GET_F_CREATE);
storage = bpf_inode_storage_get(&inode_storage_map, old_dentry->d_inode,
0, 0); if (!storage) return 0;
if (storage->value != DUMMY_STORAGE_VALUE)
inode_storage_result = -1;
err = bpf_inode_storage_delete(&inode_storage_map, old_dentry->d_inode); if (!err)
inode_storage_result = err;
storage = bpf_sk_storage_get(&sk_storage_map, sk, 0, 0); if (!storage) return 0;
sk_storage_result = -1; if (storage->value != DUMMY_STORAGE_VALUE) return 0;
/* This tests that we can associate multiple elements * with the local storage.
*/
storage = bpf_sk_storage_get(&sk_storage_map2, sk, 0,
BPF_LOCAL_STORAGE_GET_F_CREATE); if (!storage) return 0;
if (bpf_sk_storage_delete(&sk_storage_map2, sk)) return 0;
storage = bpf_sk_storage_get(&sk_storage_map2, sk, 0,
BPF_LOCAL_STORAGE_GET_F_CREATE); if (!storage) return 0;
if (bpf_sk_storage_delete(&sk_storage_map, sk)) return 0;
/* Ensure that the sk_storage_map is disconnected from the storage. */ if (!sk->sk_bpf_storage || sk->sk_bpf_storage->smap) return 0;
sk_storage_result = 0; return 0;
}
SEC("lsm.s/socket_post_create") int BPF_PROG(socket_post_create, struct socket *sock, int family, int type, int protocol, int kern)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32; struct local_storage *storage; struct sock *sk = sock->sk;
if (pid != monitored_pid || !sk) return 0;
storage = bpf_sk_storage_get(&sk_storage_map, sk, 0,
BPF_LOCAL_STORAGE_GET_F_CREATE); if (!storage) return 0;
storage->value = DUMMY_STORAGE_VALUE;
return 0;
}
/* This uses the local storage to remember the inode of the binary that a * process was originally executing.
*/
SEC("lsm.s/bprm_committed_creds") void BPF_PROG(exec, struct linux_binprm *bprm)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32; struct local_storage *storage;
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.