[PATCH] bpf, btf: Add DEBUG_INFO_BTF checks for __register_bpf_struct_ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Geliang Tang <tanggeliang@xxxxxxxxxx>

Similar to the handling in the functions __register_btf_kfunc_id_set() and
register_btf_id_dtor_kfuncs(), this patch adds CONFIG_DEBUG_INFO_BTF and
CONFIG_DEBUG_INFO_BTF_MODULES checks for __register_bpf_struct_ops() on
error path too when btf_get_module_btf() returns NULL.

Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx>
---
 kernel/bpf/btf.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index ef380e546952..381676add335 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -8880,8 +8880,15 @@ int __register_bpf_struct_ops(struct bpf_struct_ops *st_ops)
 	int err = 0;
 
 	btf = btf_get_module_btf(st_ops->owner);
-	if (!btf)
-		return -EINVAL;
+	if (!btf) {
+		if (!st_ops->owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) {
+			pr_err("missing vmlinux BTF, cannot register structs\n");
+			return -EINVAL;
+		}
+		if (st_ops->owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES))
+			pr_warn("missing module BTF, cannot register structs\n");
+		return 0;
+	}
 
 	log = kzalloc(sizeof(*log), GFP_KERNEL | __GFP_NOWARN);
 	if (!log) {
-- 
2.40.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux