aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorConnor O'Brien <[email protected]>2022-02-23 01:28:14 +0000
committerDaniel Borkmann <[email protected]>2022-02-28 14:17:10 +0100
commit5e214f2e43e453d862ebbbd2a4f7ee3fe650f209 (patch)
tree457e120feecafe35cc3475dcd897f4f25dea12f1 /kernel
parentdda7596c109fc382876118627e29db7607cde35d (diff)
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. Suggested-by: Yonghong Song <[email protected]> Suggested-by: Michal Suchánek <[email protected]> Signed-off-by: Connor O'Brien <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Shung-Hsi Yu <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/bpf/CAADnVQJ+OVPnBz8z3vNu8gKXX42jCUqfuvhWAyCQDu8N_yqqwQ@mail.gmail.com Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/btf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 0890e56e8b08..b472cf0c8fdb 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -6398,7 +6398,8 @@ static int btf_module_notify(struct notifier_block *nb, unsigned long op,
pr_warn("failed to validate module [%s] BTF: %ld\n",
mod->name, PTR_ERR(btf));
kfree(btf_mod);
- err = PTR_ERR(btf);
+ if (!IS_ENABLED(CONFIG_MODULE_ALLOW_BTF_MISMATCH))
+ err = PTR_ERR(btf);
goto out;
}
err = btf_alloc_id(btf);