summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2013-11-11 11:23:49 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-08 22:39:51 -0800
commit5123662adc873f9a37d7898fe3c285a1f1af59c8 (patch)
treece078b46046df665caee19b4a113d4ca9ced5233
parent36fe66c164a9fdf1ff4ad085b6b68960c6170000 (diff)
downloadkernel-common-5123662adc873f9a37d7898fe3c285a1f1af59c8.tar.gz
kernel-common-5123662adc873f9a37d7898fe3c285a1f1af59c8.tar.bz2
kernel-common-5123662adc873f9a37d7898fe3c285a1f1af59c8.zip
lkdtm: clean up sparse warnings
Since lkdtm intentionally does "bad" things, we need to convince sparse that we're doing these things on purpose. This adds an explicit cast to the call to copy_to_user() and marks the spin lock as expecting to dead-lock. Reported-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/lkdtm.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index a2edb2ee0921..a9a203d5f8d9 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -334,9 +334,10 @@ static void execute_location(void *dst)
static void execute_user_location(void *dst)
{
+ /* Intentionally crossing kernel/user memory boundary. */
void (*func)(void) = dst;
- if (copy_to_user(dst, do_nothing, EXEC_SIZE))
+ if (copy_to_user((void __user *)dst, do_nothing, EXEC_SIZE))
return;
func();
}
@@ -408,6 +409,8 @@ static void lkdtm_do_action(enum ctype which)
case CT_SPINLOCKUP:
/* Must be called twice to trigger. */
spin_lock(&lock_me_up);
+ /* Let sparse know we intended to exit holding the lock. */
+ __release(&lock_me_up);
break;
case CT_HUNG_TASK:
set_current_state(TASK_UNINTERRUPTIBLE);