History

bpf: Add config to allow loading modules with BTF mismatches

BTF mismatch can occur for a separately-built module even when the ABI is otherwise compatible and nothing else would prevent successfully loading. Add a new Kconfig to control how mismatches are handled. By default, preserve the current behavior of refusing to load the module. If MODULE_ALLOW_BTF_MISMATCH is enabled, load the module but ignore its BTF information.

Connor O'Brien committed 4 years ago

Commit 5e214f21 parent dda75962 files · +12 −1Browse files

Showing the changes to kernel (1 of 2 files). Show all

Unified · Split

kernel/bpf/btf.c+2−1
@@ -6398,7 +6398,8 @@ static int btf_module_notify(struct notifier_block *nb, unsigned long op, · 6397 unmodified lines
63986398 pr_warn("failed to validate module [%s] BTF: %ld\n",
63996399 mod->name, PTR_ERR(btf));
64006400 kfree(btf_mod);
6401− err = PTR_ERR(btf);
6401+ if (!IS_ENABLED(CONFIG_MODULE_ALLOW_BTF_MISMATCH))
6402+ err = PTR_ERR(btf);
64026403 goto out;
64036404 }
64046405 err = btf_alloc_id(btf);