diff mbox

[2/2] efi_runtime: Don't use get_user() on non-pointer

Message ID 1413892226-27849-3-git-send-email-matt@console-pimps.org
State Accepted
Headers show

Commit Message

Matt Fleming Oct. 21, 2014, 11:50 a.m. UTC
From: Matt Fleming <matt.fleming@intel.com>

We don't need to try to construct a pointer from a structure on the
stack in order to use get_user(). We can just access it directly.

This fixes an efi_runtime_set_waketime() failure, introduced with commit
"efi_runtime: Copied the structure from userland locally in kernel
space".

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 efi_runtime/efi_runtime.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alex Hung Oct. 22, 2014, 1:56 a.m. UTC | #1
On 14-10-21 07:50 PM, Matt Fleming wrote:
> From: Matt Fleming <matt.fleming@intel.com>
>
> We don't need to try to construct a pointer from a structure on the
> stack in order to use get_user(). We can just access it directly.
>
> This fixes an efi_runtime_set_waketime() failure, introduced with commit
> "efi_runtime: Copied the structure from userland locally in kernel
> space".
>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
>   efi_runtime/efi_runtime.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 59609bc956b2..40fb9607f504 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -394,8 +394,8 @@ static long efi_runtime_set_waketime(unsigned long arg)
>   	if (copy_from_user(&psetwakeuptime_local, psetwakeuptime, sizeof(psetwakeuptime_local)))
>   		return -EFAULT;
>   
> -	if (get_user(enabled, &(psetwakeuptime_local.Enabled)) ||
> -				copy_from_user(&efi_time, psetwakeuptime_local.Time, sizeof(EFI_TIME)))
> +	enabled = psetwakeuptime_local.Enabled;
> +	if (copy_from_user(&efi_time, psetwakeuptime_local.Time, sizeof(EFI_TIME)))
>   		return -EFAULT;
>   
>   	convert_to_efi_time(&eft, &efi_time);

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu Oct. 24, 2014, 8:43 a.m. UTC | #2
On 10/21/2014 07:50 PM, Matt Fleming wrote:
> From: Matt Fleming <matt.fleming@intel.com>
>
> We don't need to try to construct a pointer from a structure on the
> stack in order to use get_user(). We can just access it directly.
>
> This fixes an efi_runtime_set_waketime() failure, introduced with commit
> "efi_runtime: Copied the structure from userland locally in kernel
> space".
>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
>   efi_runtime/efi_runtime.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 59609bc956b2..40fb9607f504 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -394,8 +394,8 @@ static long efi_runtime_set_waketime(unsigned long arg)
>   	if (copy_from_user(&psetwakeuptime_local, psetwakeuptime, sizeof(psetwakeuptime_local)))
>   		return -EFAULT;
>
> -	if (get_user(enabled, &(psetwakeuptime_local.Enabled)) ||
> -				copy_from_user(&efi_time, psetwakeuptime_local.Time, sizeof(EFI_TIME)))
> +	enabled = psetwakeuptime_local.Enabled;
> +	if (copy_from_user(&efi_time, psetwakeuptime_local.Time, sizeof(EFI_TIME)))
>   		return -EFAULT;
>
>   	convert_to_efi_time(&eft, &efi_time);
>


Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
index 59609bc956b2..40fb9607f504 100644
--- a/efi_runtime/efi_runtime.c
+++ b/efi_runtime/efi_runtime.c
@@ -394,8 +394,8 @@  static long efi_runtime_set_waketime(unsigned long arg)
 	if (copy_from_user(&psetwakeuptime_local, psetwakeuptime, sizeof(psetwakeuptime_local)))
 		return -EFAULT;
 
-	if (get_user(enabled, &(psetwakeuptime_local.Enabled)) ||
-				copy_from_user(&efi_time, psetwakeuptime_local.Time, sizeof(EFI_TIME)))
+	enabled = psetwakeuptime_local.Enabled;
+	if (copy_from_user(&efi_time, psetwakeuptime_local.Time, sizeof(EFI_TIME)))
 		return -EFAULT;
 
 	convert_to_efi_time(&eft, &efi_time);