bpf: Only add BTF IDs for socket security hooks when CONFIG_SECURITY_NETWORK is on
authorHou Tao <houtao1@huawei.com>
Thu, 1 Sep 2022 06:51:26 +0000 (14:51 +0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 1 Sep 2022 23:21:14 +0000 (16:21 -0700)
commitef331a8d4c0061ea4d353cd0db1c9b33fd45f0f2
tree449e2f4dceecc825621dd5cc89876fb776424f9e
parentccf365eac0c7705591dee0158ae5c198d9e8f858
bpf: Only add BTF IDs for socket security hooks when CONFIG_SECURITY_NETWORK is on

When CONFIG_SECURITY_NETWORK is disabled, there will be build warnings
from resolve_btfids:

  WARN: resolve_btfids: unresolved symbol bpf_lsm_socket_socketpair
  ......
  WARN: resolve_btfids: unresolved symbol bpf_lsm_inet_conn_established

Fixing it by wrapping these BTF ID definitions by CONFIG_SECURITY_NETWORK.

Fixes: 69fd337a975c ("bpf: per-cgroup lsm flavor")
Fixes: 9113d7e48e91 ("bpf: expose bpf_{g,s}etsockopt to lsm cgroup")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20220901065126.3856297-1-houtao@huaweicloud.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
kernel/bpf/bpf_lsm.c