162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci/* 462306a36Sopenharmony_ci * Copyright (C) 2020 Google LLC. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#include <linux/lsm_hooks.h> 762306a36Sopenharmony_ci#include <linux/bpf_lsm.h> 862306a36Sopenharmony_ci 962306a36Sopenharmony_cistatic struct security_hook_list bpf_lsm_hooks[] __ro_after_init = { 1062306a36Sopenharmony_ci #define LSM_HOOK(RET, DEFAULT, NAME, ...) \ 1162306a36Sopenharmony_ci LSM_HOOK_INIT(NAME, bpf_lsm_##NAME), 1262306a36Sopenharmony_ci #include <linux/lsm_hook_defs.h> 1362306a36Sopenharmony_ci #undef LSM_HOOK 1462306a36Sopenharmony_ci LSM_HOOK_INIT(inode_free_security, bpf_inode_storage_free), 1562306a36Sopenharmony_ci LSM_HOOK_INIT(task_free, bpf_task_storage_free), 1662306a36Sopenharmony_ci}; 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_cistatic int __init bpf_lsm_init(void) 1962306a36Sopenharmony_ci{ 2062306a36Sopenharmony_ci security_add_hooks(bpf_lsm_hooks, ARRAY_SIZE(bpf_lsm_hooks), "bpf"); 2162306a36Sopenharmony_ci pr_info("LSM support for eBPF active\n"); 2262306a36Sopenharmony_ci return 0; 2362306a36Sopenharmony_ci} 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_cistruct lsm_blob_sizes bpf_lsm_blob_sizes __ro_after_init = { 2662306a36Sopenharmony_ci .lbs_inode = sizeof(struct bpf_storage_blob), 2762306a36Sopenharmony_ci .lbs_task = sizeof(struct bpf_storage_blob), 2862306a36Sopenharmony_ci}; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ciDEFINE_LSM(bpf) = { 3162306a36Sopenharmony_ci .name = "bpf", 3262306a36Sopenharmony_ci .init = bpf_lsm_init, 3362306a36Sopenharmony_ci .blobs = &bpf_lsm_blob_sizes 3462306a36Sopenharmony_ci}; 35