17 Jan, 2020
2 commits
-
The commit e91c2518a5d22a ("livepatch: Initialize shadow variables
safely by a custom callback") leads to the following static checker
warning:samples/livepatch/livepatch-shadow-fix1.c:86 livepatch_fix1_dummy_alloc()
error: 'klp_shadow_alloc()' 'leak' too small (4 vs 8)It is because klp_shadow_alloc() is used a wrong way:
int *leak;
shadow_leak = klp_shadow_alloc(d, SV_LEAK, sizeof(leak), GFP_KERNEL,
shadow_leak_ctor, leak);The code is supposed to store the "leak" pointer into the shadow variable.
3rd parameter correctly passes size of the data (size of pointer). But
the 5th parameter is wrong. It should pass pointer to the data (pointer
to the pointer) but it passes the pointer directly.It works because shadow_leak_ctor() handle "ctor_data" as the data
instead of pointer to the data. But it is semantically wrong and
confusing.The same problem is also in the module used by selftests. In this case,
"pvX" variables are introduced. They represent the data stored in
the shadow variables.Reported-by: Dan Carpenter
Signed-off-by: Petr Mladek
Reviewed-by: Joe Lawrence
Acked-by: Miroslav Benes
Reviewed-by: Kamalesh Babulal
Signed-off-by: Jiri Kosina -
The shadow variable selftest is quite tricky. Especially it is problematic
to understand what values are stored, returned, and printed.Make it easier to understand by using "int *var, **sv" variables
consistently everywhere instead of the generic "void *", "ret",
and "ctor_data".Signed-off-by: Petr Mladek
Reviewed-by: Joe Lawrence
Acked-by: Miroslav Benes
Reviewed-by: Kamalesh Babulal
Signed-off-by: Jiri Kosina
01 Nov, 2019
1 commit
-
Four selftests for the new API.
Link: http://lkml.kernel.org/r/20191030154313.13263-6-pmladek@suse.com
To: Jiri Kosina
Cc: Kamalesh Babulal
Cc: Nicolai Stange
Cc: live-patching@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Acked-by: Miroslav Benes
Acked-by: Joe Lawrence
Acked-by: Josh Poimboeuf
Signed-off-by: Petr Mladek
06 Feb, 2019
2 commits
-
Add proper error handling when allocating or getting shadow variables
in the selftest. It prevents an invalid pointer access in some situations.
It shows the good programming practice in the others.The error codes are just the best guess and specific for this particular
test. In general, klp_shadow_alloc() returns NULL also when the given
shadow variable has already been allocated. In addition, both
klp_shadow_alloc() and klp_shadow_get_or_alloc() might fail from
other reasons when the constructor fails.Note, that the error code is not really important even in the real life.
The use of shadow variables should be transparent for the original
livepatched code.Acked-by: Miroslav Benes
Acked-by: Joe Lawrence
Signed-off-by: Petr Mladek -
Fixes the following smatch warning:
lib/livepatch/test_klp_shadow_vars.c:47 ptr_id() warn: returning -1 instead of -ENOMEM is sloppy
Signed-off-by: Joe Lawrence
Acked-by: Miroslav Benes
Signed-off-by: Petr Mladek
12 Jan, 2019
1 commit
-
Add a few livepatch modules and simple target modules that the included
regression suite can run tests against:- basic livepatching (multiple patches, atomic replace)
- pre/post (un)patch callbacks
- shadow variable APISigned-off-by: Joe Lawrence
Signed-off-by: Petr Mladek
Tested-by: Miroslav Benes
Tested-by: Alice Ferrazzi
Acked-by: Joe Lawrence
Acked-by: Josh Poimboeuf
Signed-off-by: Jiri Kosina