Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61bf12d3 authored by Jiri Kosina's avatar Jiri Kosina
Browse files

livepatch: robustify klp_register_patch() API error checking



Commit 425595a7 ("livepatch: reuse module loader code to write
relocations") adds a possibility of dereferncing pointers supplied by the
consumer of the livepatch API before sanity (NULL) checking them (patch
and patch->mod).

Spotted by smatch tool.

Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Acked-by: default avatarJessica Yu <jeyu@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 3b812ecc
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -876,6 +876,9 @@ int klp_register_patch(struct klp_patch *patch)
{
	int ret;

	if (!patch || !patch->mod)
		return -EINVAL;

	if (!is_livepatch_module(patch->mod)) {
		pr_err("module %s is not marked as a livepatch module",
		       patch->mod->name);
@@ -885,9 +888,6 @@ int klp_register_patch(struct klp_patch *patch)
	if (!klp_initialized())
		return -ENODEV;

	if (!patch || !patch->mod)
		return -EINVAL;

	/*
	 * A reference is taken on the patch module to prevent it from being
	 * unloaded.  Right now, we don't allow patch modules to unload since