linux/lib/livepatch
Petr Mladek be6da98425 livepatch/samples/selftest: Use klp_shadow_alloc() API correctly
The commit e91c2518a5 ("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 <dan.carpenter@oracle.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Joe Lawrence <joe.lawrence@redhat.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2020-01-17 11:12:06 +01:00
..
Makefile livepatch: Selftests of the API for tracking system state changes 2019-11-01 13:08:29 +01:00
test_klp_atomic_replace.c selftests/livepatch: introduce tests 2019-01-11 20:51:24 +01:00
test_klp_callbacks_busy.c selftests/livepatch: introduce tests 2019-01-11 20:51:24 +01:00
test_klp_callbacks_demo.c selftests/livepatch: introduce tests 2019-01-11 20:51:24 +01:00
test_klp_callbacks_demo2.c selftests/livepatch: introduce tests 2019-01-11 20:51:24 +01:00
test_klp_callbacks_mod.c selftests/livepatch: introduce tests 2019-01-11 20:51:24 +01:00
test_klp_livepatch.c selftests/livepatch: introduce tests 2019-01-11 20:51:24 +01:00
test_klp_shadow_vars.c livepatch/samples/selftest: Use klp_shadow_alloc() API correctly 2020-01-17 11:12:06 +01:00
test_klp_state.c livepatch: Selftests of the API for tracking system state changes 2019-11-01 13:08:29 +01:00
test_klp_state2.c livepatch: Selftests of the API for tracking system state changes 2019-11-01 13:08:29 +01:00
test_klp_state3.c livepatch: Selftests of the API for tracking system state changes 2019-11-01 13:08:29 +01:00