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.
Showing the changes to kernel (1 of 2 files). Show all
Unified · Split
| @@ -6398,7 +6398,8 @@ static int btf_module_notify(struct notifier_block *nb, unsigned long op, · 6397 unmodified lines | ||
| 6398 | 6398 | pr_warn("failed to validate module [%s] BTF: %ld\n", |
| 6399 | 6399 | mod->name, PTR_ERR(btf)); |
| 6400 | 6400 | kfree(btf_mod); |
| 6401 | − err = PTR_ERR(btf); | |
| 6401 | + if (!IS_ENABLED(CONFIG_MODULE_ALLOW_BTF_MISMATCH)) | |
| 6402 | + err = PTR_ERR(btf); | |
| 6402 | 6403 | goto out; |
| 6403 | 6404 | } |
| 6404 | 6405 | err = btf_alloc_id(btf); |