* [PATCH] livepatch: robustify klp_register_patch() API error checking
[not found] <20160404203426.GA8200@mwanda>
@ 2016-04-07 16:06 ` Jiri Kosina
2016-04-07 18:04 ` Josh Poimboeuf
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jiri Kosina @ 2016-04-07 16:06 UTC (permalink / raw)
To: Dan Carpenter
Cc: jeyu, Josh Poimboeuf, Miroslav Benes, Petr Mladek, live-patching,
linux-kernel
From: Jiri Kosina <jkosina@suse.cz>
Commit 425595a7fc20 ("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: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
kernel/livepatch/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index eb5db6e..28c37fa 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -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
--
Jiri Kosina
SUSE Labs
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] livepatch: robustify klp_register_patch() API error checking
2016-04-07 16:06 ` [PATCH] livepatch: robustify klp_register_patch() API error checking Jiri Kosina
@ 2016-04-07 18:04 ` Josh Poimboeuf
2016-04-07 18:20 ` Jessica Yu
2016-04-07 20:33 ` [PATCH] " Jiri Kosina
2 siblings, 0 replies; 4+ messages in thread
From: Josh Poimboeuf @ 2016-04-07 18:04 UTC (permalink / raw)
To: Jiri Kosina
Cc: Dan Carpenter, jeyu, Miroslav Benes, Petr Mladek, live-patching,
linux-kernel
On Thu, Apr 07, 2016 at 06:06:25PM +0200, Jiri Kosina wrote:
> From: Jiri Kosina <jkosina@suse.cz>
>
> Commit 425595a7fc20 ("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: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
--
Josh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: livepatch: robustify klp_register_patch() API error checking
2016-04-07 16:06 ` [PATCH] livepatch: robustify klp_register_patch() API error checking Jiri Kosina
2016-04-07 18:04 ` Josh Poimboeuf
@ 2016-04-07 18:20 ` Jessica Yu
2016-04-07 20:33 ` [PATCH] " Jiri Kosina
2 siblings, 0 replies; 4+ messages in thread
From: Jessica Yu @ 2016-04-07 18:20 UTC (permalink / raw)
To: Jiri Kosina
Cc: Dan Carpenter, Josh Poimboeuf, Miroslav Benes, Petr Mladek,
live-patching, linux-kernel
+++ Jiri Kosina [07/04/16 18:06 +0200]:
>From: Jiri Kosina <jkosina@suse.cz>
>
>Commit 425595a7fc20 ("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: Dan Carpenter <dan.carpenter@oracle.com>
>Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Jessica Yu <jeyu@redhat.com>
Thank you Jiri!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] livepatch: robustify klp_register_patch() API error checking
2016-04-07 16:06 ` [PATCH] livepatch: robustify klp_register_patch() API error checking Jiri Kosina
2016-04-07 18:04 ` Josh Poimboeuf
2016-04-07 18:20 ` Jessica Yu
@ 2016-04-07 20:33 ` Jiri Kosina
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2016-04-07 20:33 UTC (permalink / raw)
To: Dan Carpenter
Cc: jeyu, Josh Poimboeuf, Miroslav Benes, Petr Mladek, live-patching,
linux-kernel
On Thu, 7 Apr 2016, Jiri Kosina wrote:
> From: Jiri Kosina <jkosina@suse.cz>
>
> Commit 425595a7fc20 ("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: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Jessica Yu <jeyu@redhat.com>
Pushed out. Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-07 20:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20160404203426.GA8200@mwanda>
2016-04-07 16:06 ` [PATCH] livepatch: robustify klp_register_patch() API error checking Jiri Kosina
2016-04-07 18:04 ` Josh Poimboeuf
2016-04-07 18:20 ` Jessica Yu
2016-04-07 20:33 ` [PATCH] " Jiri Kosina
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.