Age | Commit message (Collapse) | Author | Files | Lines |
|
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 <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
Reviewed-by: Joe Lawrence <[email protected]>
Acked-by: Miroslav Benes <[email protected]>
Reviewed-by: Kamalesh Babulal <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
|
|
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 <[email protected]>
Reviewed-by: Joe Lawrence <[email protected]>
Acked-by: Miroslav Benes <[email protected]>
Reviewed-by: Kamalesh Babulal <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
|
|
Four selftests for the new API.
Link: http://lkml.kernel.org/r/[email protected]
To: Jiri Kosina <[email protected]>
Cc: Kamalesh Babulal <[email protected]>
Cc: Nicolai Stange <[email protected]>
Cc: [email protected]
Cc: [email protected]
Acked-by: Miroslav Benes <[email protected]>
Acked-by: Joe Lawrence <[email protected]>
Acked-by: Josh Poimboeuf <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
|
|
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 <[email protected]>
Acked-by: Joe Lawrence <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
|
|
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 <[email protected]>
Acked-by: Miroslav Benes <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
|
|
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 API
Signed-off-by: Joe Lawrence <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
Tested-by: Miroslav Benes <[email protected]>
Tested-by: Alice Ferrazzi <[email protected]>
Acked-by: Joe Lawrence <[email protected]>
Acked-by: Josh Poimboeuf <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
|