ARM: 8790/1: signal: always use __copy_to_user to save iwmmxt context
authorJulien Thierry <julien.thierry@arm.com>
Thu, 14 Feb 2019 02:10:07 +0000 (21:10 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Feb 2019 09:20:45 +0000 (10:20 +0100)
Commit 73839798af7ebc6c8d0c9271ebbbc148700e521f upstream.

When setting a dummy iwmmxt context, create a local instance and
use __copy_to_user both cases whether iwmmxt is being used or not.
This has the benefit of disabling/enabling PAN once for the whole copy
intead of once per write.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David A. Long <dave.long@linaro.org>
Reviewed-by: Julien Thierry <julien.thierry@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm/kernel/signal.c

index 1dc1f39825b6ae192ea5c609ed1ea8dd506e9b37..b12499cc35827c096d03c227461b0bd5eb3ffe45 100644 (file)
@@ -76,8 +76,6 @@ static int preserve_iwmmxt_context(struct iwmmxt_sigframe __user *frame)
                kframe->magic = IWMMXT_MAGIC;
                kframe->size = IWMMXT_STORAGE_SIZE;
                iwmmxt_task_copy(current_thread_info(), &kframe->storage);
-
-               err = __copy_to_user(frame, kframe, sizeof(*frame));
        } else {
                /*
                 * For bug-compatibility with older kernels, some space
@@ -85,10 +83,14 @@ static int preserve_iwmmxt_context(struct iwmmxt_sigframe __user *frame)
                 * Set the magic and size appropriately so that properly
                 * written userspace can skip it reliably:
                 */
-               __put_user_error(DUMMY_MAGIC, &frame->magic, err);
-               __put_user_error(IWMMXT_STORAGE_SIZE, &frame->size, err);
+               *kframe = (struct iwmmxt_sigframe) {
+                       .magic = DUMMY_MAGIC,
+                       .size  = IWMMXT_STORAGE_SIZE,
+               };
        }
 
+       err = __copy_to_user(frame, kframe, sizeof(*kframe));
+
        return err;
 }